邮件发送失败。 asp.net中的错误 [英] Failure sending mail. error in asp .net

查看:72
本文介绍了邮件发送失败。 asp.net中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我用gmail发送邮件localy工作正常,但当我在服务器上传发送邮件失败时。发生错误。

这是我写的代码:

  Dim  message  As   MailMessage 
message.From = MailAddress( xxx@gmail.com
条消息。 .Add( MailAddress( xxx@yahoo.com))
message.Subject = test mail
message.Body = 你有一个来自我的测试邮件!
昏暗客户端作为 SmtpClient
client.Credentials = System.Net .NetworkCredential( xxx@gmail.com xxxxxxx
client.Port = 587
客户端。主机= smtp.gmail.com
client.EnableSsl = True
client.Send(message)





请帮帮我!

解决方案

如果它在本地计算机上运行而不在服务器上运行,那么由于某种原因,服务器无法访问您正在使用的邮件服务器。


可能是由于种种原因。您需要逐个查看它们。



端口是否打开?防火墙权限到位了吗?

进一步确保在Web中配置了SMTP配置。配置:

< system.net> 
< mailSettings>
< smtp from =abc@somedomain.com>
< network host =somesmtpserverport =25userName =namepassword =passdefaultCredentials =true/>
< / smtp>
< / mailSettings>
< /system.net>



如果需要,请查看此Microsoft视频教程:

使用ASP.NET从网站发送电子邮件 [ ^ ]



如果需要,本网站上有很多关于如何发送电子邮件的文章


< blockquote> NetworkCredential ncrd = new NetworkCredential();

ncrd.UserName = fromemail;

ncrd.Password = frompwd;

SmtpClient MailClient = new SmtpClient();

MailClient.Host =smtp.gmail.com;

MailClient.Port = 587;

MailClient.UseDefaultCredentials =是的;

MailClient.Credentials = ncrd;

MailClient.EnableSsl = true;

MailClient.DeliveryMethod = SmtpDeliveryMethod.Network;

MailClient.Send(msg) ;

Hi,
I have used gmail for sending mail localy which worked fine but when i uploaded the same file on server the "Failure sending mail." error occured.
Here is the code that I have written:

Dim message As New MailMessage
message.From = New MailAddress("xxx@gmail.com")
message.To.Add(New MailAddress("xxx@yahoo.com"))
message.Subject = test mail""
message.Body = "Hi you have got a test mail from me!"
Dim client As New SmtpClient
client.Credentials = New System.Net.NetworkCredential("xxx@gmail.com", "xxxxxxx")
client.Port = 587
client.Host = "smtp.gmail.com"
client.EnableSsl = True
client.Send(message)



Please help me!

解决方案

If it works on your local machine and not on the server, then the server cannot access the mail server you're using, for some reason.


It can be because of various reasons. You need to look at them one by one.

Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:

<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>


If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]

If needed, there are lots of article on this very site on how to send emails


NetworkCredential ncrd = new NetworkCredential();
ncrd.UserName = fromemail;
ncrd.Password = frompwd;
SmtpClient MailClient = new SmtpClient();
MailClient.Host = "smtp.gmail.com";
MailClient.Port = 587;
MailClient.UseDefaultCredentials = true;
MailClient.Credentials = ncrd;
MailClient.EnableSsl = true;
MailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MailClient.Send(msg);


这篇关于邮件发送失败。 asp.net中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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