使用SmtpClient发送邮件的时候,出现了如题错误。

解决方案:

将  SmtpClient.UseDefaultCredentials  属性设置为 true 。

官方文档说明:

Some SMTP servers require that the client be authenticated before the server sends e-mail on its behalf. Set this property to truewhen this  SmtpClient  object should, if requested by the server, authenticate using the default credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios.

Credentials information can also be specified using the application and machine configuration files. For more information, see  <mailSettings> Element (Network Settings) .

If the  UseDefaultCredentials  property is set to false, then the value set in the  Credentials  property will be used for the credentials when connecting to the server. If the  UseDefaultCredentials  property is set to false and the  Credentials  property has not been set, then mail is sent to the server anonymously.

谷歌翻译:

一些SMTP服务器要求客户端在服务器代表它发送电子邮件之前进行认证。 如果此服务器请求,此SmtpClient对象应使用当前登录用户的默认凭据进行身份验证,请将此属性设置为true。 对于客户端应用程序,这是大多数情况下所需的行为。

凭证信息也可以使用应用程序和机器配置文件来指定。 有关更多信息,请参阅<mailSettings>元素(网络设置)。

如果UseDefaultCredentials属性设置为false,则在连接到服务器时,Credentials属性中设置的值将用于凭据。 如果UseDefaultCredentials属性设置为false,并且尚未设置Credentials属性,则邮件将匿名发送到服务器。

官方文档:https://docs.microsoft.com/zh-cn/dotnet/api/system.net.mail.smtpclient.usedefaultcredentials?view=netframework-4.7.1

System.Net.Mail.SmtpException:不允许使用邮箱名称.的更多相关文章

  1. System.net.mail.smtpException;服务器提交了协议冲突 服务器响应为:

    最近发邮件遇到问题. 主机godaddy 端口 25,80 都可以用 stmp服务器地址:smtpout.secureserver.net 不支持ssl 我就吧 EnableSsl 设置为false了 ...

  2. C# ASP.NET发送电子邮件System.Net.Mail

    1.补充知识 (1)POP3和SMTP服务器是什么? 简单点来说:POP3 用于接收电子邮件 ,SMTP 用于发送电子邮件. (1)POP3具体指什么? POP3(Post Office Protoc ...

  3. C#中使用System.Web.Mail.MailMessage类无法CC多人的问题

    从.NET 2.0 开始,引入了一个新的类,System.Net.Mail.MailMessage.该类用来取代 .NET 1.1 时代System.Web.Mail.MailMessage类.Sys ...

  4. C#System.Net.Mail采用简单邮件传输协议发送邮件

    引用: using System.Net.Mail; public class EmailHelper { public static bool SendEmail(string title, str ...

  5. asp.net 发送邮件代码 System.Net.Mail

    前台页面 SendEmail.aspx 代码 using System.Net.Mail;using System.Net; <h2> 发送电子邮件演示 </h2> <t ...

  6. 利用System.Net.Mail和多线程实现邮件发送

    对于邮件发送,一般来说,程序会响应超过1秒,这样对于用户体验来说,让用户等待的时间过长,而且发送的邮件越多时间就越长,所以这里我利用了线程的来处理邮件发送这种耗时的工作,废话不多说,直接上代码 pri ...

  7. 利用System.Net.Mail 的SmtpClient发送邮件

    原文:利用System.Net.Mail 的SmtpClient发送邮件 几个月前总结过关于Jmail发送邮件,当时用Jmail发送邮件发送速度有点慢(可能对Jmail了解不是很多).现在改为用微软提 ...

  8. C#使用 System.Net.Mail发送邮件功能

    .NET 里包含了很多很丰富的邮件发送与接受的API在 System.Net.Mail命名空间里,使得我们开发发送和接受邮件相关功能变得简单,下面是一个简单发送邮件的功能: private void ...

  9. System.net.mail 使用ssl发送邮件失败

    我采用了.net 的自带组件System.Net.Mail发送邮件,主要是在客户注册网站成功的时候发条欢迎邮件,最近邮件无法发送了,看了下腾讯smtp邮件配置,所有的邮件发送都换成ssl了,之前用的是 ...

随机推荐

  1. CMS(1)

    一周后,终于可以学习到可爱的渗透了哈哈哈.除了大哥给的CMS(其实可以算是只是在文件上传的时候了解一下),但是对于一个CMS完整的渗透思路,我还是不懂.首先感谢章老师给我的CMS源码哈哈哈,在我的日记 ...

  2. c语言开发浏览器插件

    c语言开发浏览器插件 senk????sec???

  3. 【LeetCode】Recursion(共11题)

    链接:https://leetcode.com/tag/recursion/ 247 Strobogrammatic Number II (2019年2月22日,谷歌tag) 给了一个 n,给出长度为 ...

  4. procixx 时钟的坑

    error 1.procixx设置800M,uboot中是720M 了解到整个过程是,当procixx配置后,通过FSBL中的ps_init.c反应出来 // ARM_PLL_FDIV = 48    ...

  5. 读取的CSV

  6. 1、pip不是内部运行程序 解决方法

    一.方式一 1.切换到pip所在路径: shit+ 右键. 再此处打开运行窗口 2.执行 pip install pytest 脚本即可. 二.方式二,添加环境变量 1.将pip所在的文件路径 添加到 ...

  7. python的strip和split函数

    这两个函数都是string的类函数 1.strip是去掉字符串头尾的特定字符,分三个 aa=' bb=aa.rstrip(') cc=aa.lstrip(') dd=aa.strip(') print ...

  8. JPA @Id 和 @GeneratedValue 注解详解

    JPA @Id 和 @GeneratedValue 注解详解   @Id: @Id 标注用于声明一个实体类的属性映射为数据库的主键列.该属性通常置于属性声明语句之前,可与声明语句同行,也可写在单独行上 ...

  9. 输入流之顶层抽象InputStream

    该类是所有二进制输入流的的抽象父类 类中主要方法解释说明如下 (1)public abstract int read() throws IOException; 该方法是从输入流中读取下一个字节,返回 ...

  10. php pow()函数 语法

    php pow()函数 语法 作用:pow()函数的作用是将一个数进行n次方计算后返回,广东大理石平台 语法:pow(X,Y); 参数: 参数 描述 X 要做处理的数字 Y 指定n次方中的n数值 说明 ...