Smtp邮件发送到其他域

时间:2013-12-31 08:54:12

标签: c# asp.net .net wpf wcf

我使用以下代码从我的WCF服务获得邮件发送功能。 现在,我可以将邮件发送到同一域的所有电子邮件。 (" mydomain.com")。但我无法将邮件发送到其他域名,如gmail.com或yahoo.com。等等使用mail.mydomain.com"。有人解决了这个问题或者告诉我原因吗?

message.From = "admin@mydomain.com";
message.Body = mailInfo.MessageBody;
message.To.Add("test@gmail.com");
message.Subject = "test subject;
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
if (mailInfo.Attachment1 != null && mailInfo.Attachment1.Length > 0)
{
    message.Attachments.Add(new Attachment(new MemoryStream(mailInfo.Attachment1), mailInfo.Attachment1Name));
}

var smtp = new SmtpClient("mail.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredentialadmin@mydomain.com, CryptoHelper.Decrypt(adminpassword));
smtp.EnableSsl = false;
object usrtkn = message;
smtp.SendCompleted += smtp_SendCompleted;
smtp.SendAsync(message, usrtkn);

0 个答案:

没有答案