公司的邮件服务器是SSL的,端口号465 用Outlook能发,用SmtpClient就不行,提示“操作已超时”
126,gmail的邮箱都可以发
gmail端口用465也不行,但是用587就可以
郁闷了,不知道怎么解决了代码:MailMessage msg = new MailMessage(fromMail,toMail,subject,body);
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new NetworkCredential(UserName, Password);
smtp.Port = Port;
smtp.Host = ServerName;
smtp.EnableSsl = true;
smtp.Send(msg);
126,gmail的邮箱都可以发
gmail端口用465也不行,但是用587就可以
郁闷了,不知道怎么解决了代码:MailMessage msg = new MailMessage(fromMail,toMail,subject,body);
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new NetworkCredential(UserName, Password);
smtp.Port = Port;
smtp.Host = ServerName;
smtp.EnableSsl = true;
smtp.Send(msg);
解决方案 »
- 我想用jQuery来向另一个页面进行传参,同时跳转过去那个页面
- 创建了一个递归的产品分类表,怎么查询自己要的数据.
- 查询返回结果集,除了dataset还有什么类型
- 翻译成没有为类型String和String的一维数组定义运算符"+",
- 关于div的一个问题
- 在線求救~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- datagrid的update的问题总是无法实现更新
- 求救?????怎么老显这个错误??请高手们指导一下菜鸟?
- asp.net网站整合动网论坛dvbbs谁会? 跪求高人啊!
- 海量数据查询:速度怎么解决?Datagrid分页只显示前面的数据,点击下一页才继续查询,如何做到??
- 。net网站一个月执行一次方法
- 实现图书点击率功能
带SSL的除了gmail能用SmtpClient发邮件吗???
客户的发件服务器用587也不行,
也试过用默认的端口25,EnableSsl=false 都不行
我现在是要用公司的邮件服务器发,不是gmail的
mail.UseDefaultCredentials = false;
mail.Credentials = new System.Net.NetworkCredential("[email protected]", "passworcd");
//mail.Credentials = new System.Net.NetworkCredential();
mail.Timeout = 20000;
mail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("utf-8");
//發件人電子郵件
System.Net.Mail.MailAddress senderAddress = new System.Net.Mail.MailAddress(txtFromAddress.Value, txtFromName.Value);
//收件人電子郵件
System.Net.Mail.MailAddress addresseeAddress = new System.Net.Mail.MailAddress(txtToAddress.Value, txtToName.Value); System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(senderAddress, addresseeAddress);
message.IsBodyHtml = true;
message.Body = "<a>測試啦!!</a>";
message.Subject = "測試啦!!"; message.SubjectEncoding = encoding;
message.BodyEncoding = encoding;
try
{
mail.Send(message);
}
catch
{
}
但是我要的是带SSL的(除了Gmail)
用 System.Web.Mail.SmtpMail都可以发,没道理System.Net.Mail。SmtpClient不能发啊
public bool TestSendMail()
{
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
try
{
mail.To = txtEmailAddress.Text;
mail.From = UserName;
mail.Subject = "subject";
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
mail.Body = "body";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", UserName); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Password); //set your password here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", Port);//set port
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//set is ssl
System.Web.Mail.SmtpMail.SmtpServer = ServerName;
System.Web.Mail.SmtpMail.Send(mail);
return true;
}
catch (Exception ex)
{
ex.ToString();
}
return false;
}