Why can't i send email from my servlet?

前端 未结 5 607
逝去的感伤
逝去的感伤 2020-12-22 13:12

I am trying to send an email from my servlet. There is no exception but i am not getting email in my account. I am using the following code:

 public class Se         


        
相关标签:
5条回答
  • 2020-12-22 13:29

    Are you running an e-mail server on your localhost? If so, does it have authentication disabled?

    Maybe you can see the error messages in its logs.

    0 讨论(0)
  • 2020-12-22 13:41

    Generally you can use JavaMail to send mail using servlets. You stated that you are using AppEngine ( Why can't i send email from my servlet and getting java.security.AccessControlException? ). Google App Engine allows you to send email using JavaMail, But you cannot use JavaMail provided by appengine to connect to any mail server.SMTP configuration added to the Transport or Session is ignored. https://developers.google.com/appengine/docs/java/mail/usingjavamail#JavaMail_Features_Not_Supported

    0 讨论(0)
  • 2020-12-22 13:46

    it seems like mistake is :

    props.put("mail.smtp.host","localhost");
    

    it should not be localhost until you are running mail server on your system..

    look at this question : Using Javamail to connect to Gmail smtp server ignores specified port and tries to use 25

    and yes as commented by Axel try with commandline first

    0 讨论(0)
  • 2020-12-22 13:46

    The reason is , you are using localhost as the smtp host , you should use deploy mail server on your computer before using localhost as a sender. Even after that you may require to register your server.

    you can also do that using gmail or yahoo mail. Use the smtp host of google mail. Authenticate using your creds and then go ahead.

    try this link :

    http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/

    0 讨论(0)
  • 2020-12-22 13:49

    Read https://developers.google.com/appengine/docs/java/mail/overview Basically stop including any JavaMail libraries in your app and don't try to connect to a host. Build the message and jump straight to Transport.send(msg);

    0 讨论(0)
提交回复
热议问题