发送电子邮件没有身份验证在java使用gmail smtp服务器和javamail

问题描述:

我使用Javamail api和gmail smtp服务器在java中发送邮件而不给出密码。我使用下面的代码。这里我使用javax.mail jar文件

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);

我收到以下错误

      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

首先,属性的名称是mail.smtp.starttls.enable。

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

第二,不,您不能通过Gmail发送邮件,而无需先验证,例如使用您的密码。

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