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

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

问题描述

我试图通过C#发送电子邮件。尽管我相信我做的一切都正确,但它仍然会抛出这个异常:



SMTP服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1需要身份验证。详细信息请参阅



起初我想,它可能是区域/ IP /区域问题。但是当我登录到Gmail时,没有任何警告。可以肯定的是,我已经上传了一个文件到一个网站去检查,但仍然出现错误。



比我试过将端口改为465 。它也没有工作。



我第一次尝试使用由Google Apps帐户管理的帐户。所以我认为它可能是它,但它不是......

我现在真的没有想法。



您有任何想法吗?

以下是示例代码:

  SmtpClient sm =新的SmtpClient(smtp.gmail.com,587); 

sm.Credentials = new NetworkCredential(blabla@gmail.com,**);
sm.UseDefaultCredentials = false;
sm.EnableSsl = true;
sm.DeliveryMethod = SmtpDeliveryMethod.Network;
sm.Send(blabla@gmail.com,blabla2@tr3reklam.com,Test,Test);

**注意**
我已经检查过帐户名称和密码,

解决方案

必须为NetworkCredential使用的Gmail帐户启用访问安全性较低的应用程序,方法是使用 Google的设置页面


I'm trying to send email through C#. Although I beleive I've done everything right, it still throws this exception :

"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"

At first I thought, it could be a zone/ip/region problem... But when i logged into gmail, there wasn't any warning of that. And to be sure, i've uploaded a file to a website to check from there, still the error was thrown.

Than I've tried changing the port to 465. It didn't work either.

I've first tried with accounts that are managed by a Google Apps account. So I thought it could be it, but it wasn't either...

I'm truly out of ideas right now.

Any of you have an idea ?

Here is the example code :

   SmtpClient sm = new SmtpClient("smtp.gmail.com",587);

        sm.Credentials = new NetworkCredential("blabla@gmail.com","**");
        sm.UseDefaultCredentials = false;
        sm.EnableSsl = true;
        sm.DeliveryMethod = SmtpDeliveryMethod.Network;
        sm.Send("blabla@gmail.com","blabla2@tr3reklam.com","Test","Test");

** Note ** I've checked the account name and password, they both are right.

解决方案

"Access for less secure apps" must be enabled for the Gmail account used by the NetworkCredential using Google's settings page.

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

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