我该怎么做“请在您的邮件客户端打开SMTP身份验证” [英] How do I do this "please turn on SMTP authentication in your mail client"
问题描述
这是我的代码,它会将邮件发送到同一服务器上的地址,但不会发送到其他地方。
private void sendEmail(string strFrom
,string strTo
,string strSubject
,string strBody
,string strAtch)
{
///作者,Md.Marufuzzaman
// /创建,
///本地依赖,Microsoft .Net框架
///说明,使用(SMTP)发送电子邮件。
MailMessage objMailMessage = new MailMessage();
System.Net.NetworkCredential objSMTPUserInfo =
new System.Net.NetworkCredential();
SmtpClient objSmtpClient = new SmtpClient();
尝试
{
objMailMessage.From =新邮件地址(strFrom);
objMailMessage。 To.Add(new MailAddress(strTo));
objMailMessage.Subject = strSubject;
objMailMessage.Body = strBody;
objMailMessage.Attachments .Add(new Attachment(strAtch));
objMailMessage.IsBodyHtml = false;
objSmtpClient = new SmtpClient(vistagamebirds.co.nz); ///服务器IP
objSmtpClient.EnableSsl = true;
objSMTPUserInfo = new
System.Net.NetworkCredential(bill@vistgamebirds.co.nz,Secret);
objSmtpClient。凭证= objSMTPUserInfo;
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Send(objMailMessage); < br $>
}
catch(exception ex)
{MessageBox.Show(this,ex.Message); }
终于
{
objMailMessage = null;
objSMTPUserInfo = null ;
objSmtpClient = null;
}
}
我尝试了什么:
几乎我在网上找到的所有东西
here is my code, it will send mail to an address on the same server but not anywhere else.
private void sendEmail(string strFrom
, string strTo
, string strSubject
, string strBody
, string strAtch)
{
/// Author, Md. Marufuzzaman
/// Created,
/// Local dependency, Microsoft .Net framework
/// Description, Send an email using (SMTP).
MailMessage objMailMessage = new MailMessage();
System.Net.NetworkCredential objSMTPUserInfo =
new System.Net.NetworkCredential();
SmtpClient objSmtpClient = new SmtpClient();
try
{
objMailMessage.From = new MailAddress(strFrom);
objMailMessage.To.Add(new MailAddress(strTo));
objMailMessage.Subject = strSubject;
objMailMessage.Body = strBody;
objMailMessage.Attachments.Add(new Attachment(strAtch));
objMailMessage.IsBodyHtml = false;
objSmtpClient = new SmtpClient("vistagamebirds.co.nz");/// Server IP
objSmtpClient.EnableSsl = true;
objSMTPUserInfo = new
System.Net.NetworkCredential("bill@vistgamebirds.co.nz", "Secret");
objSmtpClient.Credentials = objSMTPUserInfo;
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Send(objMailMessage);
}
catch (Exception ex)
{ MessageBox.Show(this, ex.Message); }
finally
{
objMailMessage = null;
objSMTPUserInfo = null;
objSmtpClient = null;
}
}
What I have tried:
almost every thing I can find on the web
推荐答案
您的SMTP配置或您要发送给的人是一个问题。代码不是问题(除非您的SMTP服务器需要特定设置)。无论如何,这不是代码问题,而是STMP设置问题。我建议你使用你的SMTP管理员,如果你是,那么谷歌错误。关于如何解决该错误有很多建议。
It is a problem with either your SMTP configuration or the person's you are sending to. It is not a problem with the code (unless your SMTP server needs a specific setting). Regardless, this is not a code issue but an STMP setup issue. I suggest getting with your SMTP admin and if that is you then google the error. There are lots of suggestions on how to fix that error.
这篇关于我该怎么做“请在您的邮件客户端打开SMTP身份验证”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!