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("admingae#tecurti.com", "Adming"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("name#gmail.com", "Felipe"));
msg.setSubject("Assunto", "UTF-8");
msg.setText("texto corpo");
Transport.send(msg);
I´ve already give to admingae#tecurti.com "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
In console go to App Engine > Settings > Application Settings. Add this email address to the list of authorized senders.
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
Related
I am trying to user spring java mail with theses properties :
mail:
host: smtp.mail.yahoo.com
port: 587
username: xxx
password: xxx
protocol: smtp
properties.mail.smtp:
auth: true
starttls.enable: true
Code :
#Inject
private JavaMailSenderImpl javaMailSender;
...
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
message.setTo(to);
message.setFrom(fromEmail);
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);
But I am getting this error when I send the mail :
E-mail could not be sent to user 'xxx#yahoo.fr', exception is:
Authentication failed; nested exception is
javax.mail.AuthenticationFailedException: 535 5.7.0 (#MBR1212)
Incorrect username or password.
I am sure my login/pwd are correct.
Are my properties incorrect?
Check your username / password, are you parsing it with plain text,string variable or char array, does it contains special character that needed to be escaped?
Make sure there is no empty space, extra space/break.
Your code and config are too narrow ,we can't help much to be honest.
Are you able to send email using gmail account or other email?
If you do so, there are problems in either yahoo config,such as port or
the username password are indeed really incorrect.
This is most likely Yahoo's new sign in method restrictions.
Try this:
https://help.yahoo.com/kb/mail-for-desktop/turn-account-key-sln25781.html
or this:
https://login.yahoo.com/account/security#less-secure-apps
Yes I am also using Yahoo mail and connecting with Java mail, you need to set up a third party access key, and then you will be able to connect.
Good morning to all,
I was try send external email in my organization does not working for me.When i was try internel email address it working fine.. I am getting exception "invalid mail address 5.1.7 unable to relay"
I am also try send with external email via TELNET. Its working fine in TELNET.
Exchange 2013 receive connector anonymous relay was enable.
Properties props = System.getProperties();
props.put(SMTP_HOST_KEY,smtphost);
Session session=null;
System.out.println("Entering into sendSMTPMail=============(props)"+props);
MailAuthentication authorization =new EmailManager().new MailAuthentication();
LogWriter.log("CREATING THE DEFAULT SESSION");
System.out.println("Entering into sendSMTPMail=============(AUTHORIZATION)"+AUTHORIZATION);
System.out.println("Entering into sendSMTPMail=============(authorization)"+authorization);
System.out.println("Entering into sendSMTPMail=============(session)"+session);
if(AUTHORIZATION)session = Session.getInstance(props, authorization);
else session = Session.getInstance(props, null);
session.setDebug(debug);
System.out.println("Entering into sendSMTPMail=============(session)"+session);
OUTPUT in java :
Send is OK
rcpt is Invaild mail address 5.1.7 unable relay
OUTPUT in TELNET:
Send is OK
rcpt is OK
Help is needed......Please let me know what is problem in javacode or exchange 2013
Thanks.....
Our application uses javax.mail.MimeMessage, we are written this code
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress("mail#xyz.com", "XYZ"));
From section changing work in gmail and yahoo but not working outlook,
can any tell reason for this.
You need to add msg.setSender(new InternetAddress(...));
I am sending a mail in GWT using Google Oauth Authentication and token.
My Project use Google OAuthAuthentication.
The mail is send successfully . I just want to automatically include signature like we do in our mails while sending the mail.
I am able to send mail :
SMTPTransport transport = connectToSmtp(from, token);
Message msg = new MimeMessage(session);
msg.addRecipient(Message.RecipientType.TO,new InternetAddress(toMail));
msg.addRecipients(Message.RecipientType.CC, InternetAddress.parse(ccMail));
msg.setFrom(new InternetAddress(from));
msg.setSubject("Imprest Report");
msg.setContent(messageBody ,"text/html; charset=utf-8");
transport.sendMessage(msg,msg.getAllRecipients());
You would have to add the signature as part of the "content" since I don't think email APIs supports signature as a concept
I have an online form that allows users to email a complaint to the company. To test it I have used gmail smtp as my host. I have no problem receiving the message to the designated email account when the sender is also a gmail but I want the "From" to not be limited to just gmail accounts. It appears that smtp is only good for sending emails from the same server?
Example: My form works great if the from is abc#gmail.com and the company email is company#gmail.com.
However if xyz#yahoo.com is entered for the sender, the receiver company#gmail.com never gets it.
Any help would be greatly appreciated. I can provide my code as well if that is needed.
Your problem is a common security restriction when using SMTP. Outgoing SMTP email can only contain a "mail from" address belonging to the sender. If you break this rule, your email may be considered SPAM.
The following will allow your recipient to reply to an alternate address.
Properties properties = new Properties();
props.put("mail.smtp.from", "abc#gmail.com");
Session session = Session.getDefaultInstance(props, null);
MimeMessage m = new MimeMessage(session);
m.addFrom(InternetAddress.parse("xyz#yahoo.com"));
m.setReplyTo(InternetAddress.parse("xyz#yahoo.com"));
See also
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/
http://www.openspf.org/Best_Practices/Webgenerated
Well you will have to own the other email as well as set it to work with gmail,
Check here for more details.
It's probably better to send the message to your company's mail server using the identity of the user who owns the application on the server, and include the information that the customer provides in the online form as data in the message you send. The message won't look like it came from the customer, but then it really didn't come from the customer since it wasn't sent using the customer's mail server.