[英]Error occurred while sending mail from web application after hosting on server in asp.net
I am Sending mail with smtpclient Object. 我正在使用smtpclient对象发送邮件。 Mail sends locally, but mail sending fails when web application hosted on server(on BigRocks), I have following error occured.
邮件在本地发送,但是当Web应用程序托管在服务器上(在BigRocks上)时,邮件发送失败,发生了以下错误。
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
请求类型为'System.Security.Permissions.SecurityPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败。
MailMessage mailmsg = new MailMessage();
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate,
X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
mailmsg.From = new MailAddress("xxx@gmail.com");
mailmsg.To.Add(xxx);
mailmsg.Subject =....
mailmsg.Body = .....
}
mailmsg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("xxx@gmail.com", "xxxx");
smtp.EnableSsl = true;
smtp.Send(mailmsg);
Thanks:) 谢谢:)
Would you try to add trust level in web.config 您是否会尝试在web.config中添加信任级别
<system.web>
<trust level="Full" />
</system.web>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.