1

I trying to send email from server using JavaMail and smtp protocol. The email is name@mydomain.com. JavaMail is throwing the exception above and this message "Client does not have permissions to send as this sender ". Can someone tell me what to do? I have my email configured with 365 server.

Exception in thread "main" java.lang.RuntimeException: com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.60 SMTP; Client does not have permissions to send as this sender

at ao.co.karrega.test.ExtendedKarregaEmail.Send(ExtendedKarregaEmail.java:120)
at ao.co.karrega.test.mainEmail.main(mainEmail.java:11)

Caused by: com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.60 SMTP; Client does not have permissions to send as this sender

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1862)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1100)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at ao.co.karrega.test.ExtendedKarregaEmail.Send(ExtendedKarregaEmail.java:115)
... 1 more

1 Answers1

2

You can't relay anonymously. There are a few things to be aware of with O365.

  • You have to connect on port 587 (not 25)
  • You must use TLS
  • You have to authenticate to the service first
  • You have to use the same account you authenticate with in the FROM address.

If you can't support that from the application you may need to setup an internal SMTP relay that can connect with those parameters, or use a full mail server or service that can route the message via MX records (this will go out and come in to O365 and be accepted as an external message). SendGrid is an example of a service you could use.

Jesus Shelby
  • 1,294
  • 9
  • 14