Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppEngine Email : Unauthorized Sender

When I try to send mail I get a "Unauthorized sender" exception

javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Illegal Arguments (java.lang.IllegalArgumentException: Unauthorized Sender: Unauthorized sender)) at javax.mail.Transport.send(Transport.java:163) at javax.mail.Transport.send(Transport.java:48)

My code to send mail is very simple:

Session session = Session.getDefaultInstance(new Properties(), null);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]", "Adming"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]", "Felipe"));
msg.setSubject("Assunto", "UTF-8");
msg.setText("texto corpo");
Transport.send(msg);

I´ve already give to [email protected] "owner" permission on admin console.

Here is my App Engine Console permission

If anyone could help me I appreciated

thanks


Solutions Thanks to Andrei Volgin I will register the solution

Admin Console Correct Register

like image 862
Felipe Regalgo Avatar asked Mar 07 '16 20:03

Felipe Regalgo


2 Answers

In console go to App Engine > Settings > Application Settings. Add this email address to the list of authorized senders.

like image 150
Andrei Volgin Avatar answered Nov 06 '22 07:11

Andrei Volgin


Today this is little different and requires more setup for security reasons.

The zero configuration way, is sending email from an email address with this format:

[anything]@[project_id].appspotmail.com

FYI: https://cloud.google.com/appengine/docs/standard/java/mail/#who_can_send_mail

like image 38
Daniel De León Avatar answered Nov 06 '22 05:11

Daniel De León