必须首先发出STARTTLS命令 [英] Must issue a STARTTLS command first

查看:592
本文介绍了必须首先发出STARTTLS命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Gmail 帐户运行这个简单的示例,但它无效并发出以下错误:

I am running this simple example with my Gmail account, but its not working and giving the following error:

      send failed, exception: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. nv2sm4478384pbb.6      

这是我的代码

   public class Email
{
   public static void main(String [] args)
   {

       Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.googlemail.com");
        props.put("mail.from", "myemail@gmail.com");
          Session session = Session.getInstance(props, null);

        try {
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom();
            msg.setRecipients(Message.RecipientType.TO,
                              "myemail@hotmail.com");
            msg.setSubject("JavaMail hello world example");
            msg.setSentDate(new Date());
            msg.setText("Hello, world!\n");
            Transport.send(msg);
        } catch (MessagingException mex) {
            System.out.println("send failed, exception: " + mex);
        }
   }
}


推荐答案

您可能尝试使用端口25上的Gmail服务器通过未经身份验证的连接向第三方发送邮件。 Gmail不允许您这样做,因为任何人可以使用Gmail的服务器向任何其他人发送邮件。这被称为开放中继,并且在早期是垃圾邮件的常见推动者。 Internet上不再接受开放式中继。

You are probably attempting to use Gmail's servers on port 25 to deliver mail to a third party over an unauthenticated connection. Gmail doesn't let you do this, because then anybody could use Gmail's servers to send mail to anybody else. This is called an open relay and was a common enabler of spam in the early days. Open relays are no longer acceptable on the Internet.

您需要让SMTP客户端使用经过身份验证的连接来连接到Gmail,可能是在端口587

You will need to ask your SMTP client to connect to Gmail using an authenticated connection, probably on port 587.

这篇关于必须首先发出STARTTLS命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆