使用c#生成邮件时出现问题 [英] Problem in mail generation using c#
本文介绍了使用c#生成邮件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码通过C#代码生成邮件
SmtpClient smtp = new SmtpClient ( smtp.live.com, 587 跨度>);
smtp.EnableSsl = true ;
smtp.UseDefaultCredentials = false ;
smtp.Credentials = new NetworkCredential( XYZ@live.com, ********) ;
MailMessage mail = new MailMessage( XYZ @ live.com, ABC@live.com, 已注册查询,( 亲爱的先生 + \\\\ n + \\\\ n + TextBox4.Text + \\\\ n + \\\\ n + TextBox1.Text + \\\\ n + TextBox3.Text + \\\\ n + TextBox2.Text ));
smtp.Send(mail);
Response.Redirect( Submitbtn.aspx);
当我在我的本地计算机上运行时,它正常脱机工作,
但是我在发布网站后将其上传到服务器上却无法帮助.................. ......
解决方案
尝试在服务器上配置证书
我在linux服务器上遇到同样的问题,之后我在终端写了这个:
certmgr -ssl smtps://smtp.gmail.com:465
mozroots --import --ask-remove
一切正常
I am using below code to generate mail through C # code
SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("XYZ@live.com", "********");
MailMessage mail = new MailMessage("XYZ@live.com", "ABC@live.com", "Registered Query", ("Dear Sir" + "\r\n " + "\r\n " + TextBox4.Text + "\r\n " + "\r\n " + TextBox1.Text + "\r\n" + TextBox3.Text + "\r\n" + TextBox2.Text));
smtp.Send(mail);
Response.Redirect("Submitbtn.aspx");
It was working properly offline when i running on my local computer,
But I uploading it on server after publishing website it is not working kindly help……………………
解决方案
Try to configure certificates on server
I had the same problem on linux server, and after i wrote this in terminal:
certmgr -ssl smtps://smtp.gmail.com:465
mozroots --import --ask-remove
all worked fine
这篇关于使用c#生成邮件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文