Is there a way to check if the email was received or not using spring framework's email functions?
You cannot check whether the email was received. The only errors that will be reported are those during the send process (Invalid address, wrong smtp credentials, etc.).
After the mail gets sent by the mail server, things are out of your business. What you could do is to check whether the receivers mail server sends a bounce (blocked email. full post box, no such address, etc.). But that have to happen outside the mail send process. Most likely done by a scheduler some time after emails have been sent.
Related
While sending the schedule meeting email from our java application, we are creating an ics file through MIME object and its works perfect
While cancelling the meeting the mail is bounced back with 550-5.7.26
Error Description from Google
550, "5.7.26", " Unauthenticated email from domain-name is not accepted due to domain's DMARC policy. Please contact the administrator of domain-name domain. If this was a legitimate mail please visit Control unauthenticated mail from your domain to learn about the DMARC initiative. If the messages are valid and aren't spam, contact the administrator of the receiving mail server to determine why your outgoing messages don't pass authentication checks.
Below is the only difference in ics file between schedule and cancel email
For schedule invite
METHOD:REQUEST
STATUS:CONFIRMED
For cancel invite
METHOD:CANCEL
STATUS:CANCELLED
All other attributes(ORGANIZER, ATTENDEE ) are same
ORGANIZER;CN=<name>#<domain>.net:mailto:<name>#<domain>.net
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=<name>#gmail.com:mailto:<name>#gmail.com
And interesting things are:
We are facing this issue only when we send through MS graph((through MIME object)) not with
normal SMTP config
And the same ics is working fine for the outlook recipient. its not
working only for gmail recipient
Can any one please help with the below queries?
Why its only failing for cancel invite and working for sent invite?
What is the difference in consuming ics between request and cancel methods?
Why its working with normal SMTP config and not with MS
graph?
Why its not working only for gmail recipient?
I have a spring MVC application where I want to send a no-reply email after each user registration.
To send a no-reply email, what all configuration needs to do in service providers like Gmail or anything, we need to write extra code in java.
or is there any 3rd party tool available which handles this?
There is no magic for this. A "no reply" email is one which has a Reply-to: address that goes to a mailbox that will be ignored or discarded. Usually you use a mailbox name that indicates to the user that their reply will be ignored.
For example:
Reply-to: no-replies#example.com # assuming 'example.com' is your domain.
Typically you don't want replies to the "no reply" email to bounce. But that is an option too.
To send a no-reply email , what all configuration need to do in service provider like gmail or anything we need to write extra code in java.
No configuration is needed. You just code the mail sender (e.g. your Java application) to include a "Reply-to:" header.
However, you will need to set up the mail server that hosts the "no reply" mailbox so the the emails are discarded.
Note: it would be a bad idea to use a 3rd-parties email domain (real or fake) for your "no reply" email address. Why? Because some people reply to the "no reply" address anyway. If the domain is owned by someone else, there is nothing to stop them from setting up a mail server to capture the emails ... and harvest confidential information.
I got a requirement which I don't know how to get started.
Requirement:
The application will send emails to clients (using org.springframework.mail.javamail.JavaMailSender) with same "from email address" as support#mydomain.com. Also the email content will have some hidden information such as client_id. If the client reply back to that email, I need to get that as an HttpServletRequest to a Servlet so that I can process it.
EDIT:
This web application does not have google app engine setup, but my requirement is matching similar to this link.
When someone replies to the mail you sent him that mail will go to the POP3 server configured for your domain. From this SMTP server you can read this mail using the Java Mail API. You can have a Spring timer task to keep polling this mailbox after every few seconds.
I would look at the below resources to see how to read mail from the POP3 server -
Using JavaMail API -
http://metoojava.wordpress.com/2010/03/21/java-code-to-receive-mail-using-javamailapi
Using Spring -
http://blog.solidcraft.eu/2011/04/read-emails-from-imap-with-spring.html
Better and popular solution is to have a link in your email and asking user to click it and asking specifically not to reply to this email (from address can be noreply#domain.com)
For getting a servlet call in an email reply, you need to use
http://javamail.kenai.com/nonav/javadocs/com/sun/mail/pop3/package-summary.html
Keep polling for new emails in your reply address(for eg support#domain.com) using POP, and when new email comes trigger a httprequest(HttpClient? ).
On a related note you can add user_id and similar stuff using a + in reply email address
For eg support#domain.com and support+uid_21_catid_32#domain.com will deliver to same address. Everything after + is ignored. But you will get this info in reply email event as to address and decide on who is the user.This could be a security concern for sure if not properly implemented.
I writing a mail client for sending of email notification using Javax.mail SMTP. I need to validate the mail delivery. my first step ofcourse was to catch built in exception.
My question does those exceptioon cover delivery errors (i.e. failed delivery becouse of wrong adrress, target server not found etc) or do I need to do extra work to cover that.
Thanks,
Alex
Once the email is successfully delivered to the destination server, it's gone. If that server is a relay (as you would typically find in a corporate environment) the message could bounce later when the relay tries to send it to the real destination.
At that poing, a bounce message would be returned to the sending address. If you need to handle those, you need to ensure that the sending address is deliverable to a mailbox to which you have access. Then you need to somehow (i.e. procmail) get the incoming bounces to another program you write which handles them.
I am trying to send simple text mail to myself from a servlet using Java Mail API. I wonder how to best approach this in order to avoid daily sent limits meant to restrict sending mail to other people.
How does a mail server receive email? From what information I could find, it is through the SMTP protocol? When the receiver happens to be local, instead of a relay the SMTP server assumes the role of local mail delivery agent. Is that correct? Any problems I could bump into when I connect directly to my SMTP server?
To avoid any confusion, I want my servlet to act as an SMTP server, NOT a mail client that connects to one. I want to make a mail server to RECEIVE a message going to my mail box, not relay one to other people.
Yes, SMTP is the protocol that a client uses to send an email message to a remote server.
Depending on the server software, there may be ways to send a message to a local server without using SMTP, but (as far as I know) the Java mail framework doesn't know about any of those, it can only use SMTP. So if there are limits on how much you can send, you'll just have to fix those limits directly.
If you want to test sending mail from your java application, and you have no development server to connect to, then install a local email server (hmailserver for windows, postfix for *nix).
Configure your email server to only receive email from localhost, and to only deliver to local clients (that way you wont spam the world with your test emails).
Once your happy with your application, you can point it at a production email server. How you connect and the amount of emails you can send will depend on your provider. If you are hosting your own email server you should get professional advice (or do a lot of reasearch) to prevent becoming a spammer, or having a spammer abuse your service (google for open relay).
The postfix site has plenty of good documentation and hmail server has a very good gui.