Send Email Without authentication in java using gmail smtp server and javamail

♀尐吖头ヾ 提交于 2019-12-31 06:10:21

问题


I am using Javamail api and gmail smtp server to send mail in java without giving password. I have using the below code. here i am using javax.mail jar file

     Properties props= new Properties();

     props.put("mail.smtp.host", "smtp.gmail.com");
     props.put("mail.smtp.port", 587);
     props.put("mail.transport.protocal", "smtps");
     //Put below to false, if no https is needed
     props.put("mail.smtp.STARTTLS.enable", "false");
     props.put("mail.smtp.auth", "false");

     Session session = Session.getInstance(props);

I am getting the below error

      Must issue a STARTTLS command first. b4sm3005855pdh.2 - gsmtp

Is there any wrong in implementing the code? is it posssible to implement without password ? pls any one help me on this


回答1:


First, the name of the property is "mail.smtp.starttls.enable".

Second, no, you can't send mail through Gmail without authenticating first, e.g., using your password.




回答2:


I Think it is not possible . if it will happen , any body can misuse of any other's mail address.



来源:https://stackoverflow.com/questions/26300755/send-email-without-authentication-in-java-using-gmail-smtp-server-and-javamail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!