[英]This is the code I use to send an email using the service of Exchange Server
public void ReplyMessage(string subject, string body, string to)
{
EmailMessage message = new EmailMessage(service);
message.Subject = "re: " + subject;
message.Body = body;
message.ToRecipients.Add(to);
message.SendAndSaveCopy();
}
My question is will it also send to gmail or hotmail emails?我的问题是它还会发送到 gmail 或 hotmail 电子邮件吗?
That completely depends on the setup of your mail server, it is generally common practice that either the from or to address needs to be a domain serviced by the mail server.这完全取决于您的邮件服务器的设置,通常的做法是,发件人或收件人地址需要是邮件服务器服务的域。 So if your mail server is mymail.com, as long as its from me@mymail.com it would be able to send to gmail/yahoo/hotmail - assuming you havent managed to get on one of the black lists.因此,如果您的邮件服务器是 mymail.com,只要它来自 me@mymail.com,它就可以发送到 gmail/yahoo/hotmail - 假设您没有设法进入黑名单之一。 Similarly, if you send it to yourself from an external address that will probably work fine too.同样,如果您从外部地址将其发送给自己,也可能会正常工作。
However, open relaying (eg sending in my example from say me@gmail.com to me@hotmail.com) will normally fail because the server would end up abused and end up on black lists and often then block proper mail too.但是,开放式中继(例如,在我的示例中从 me@gmail.com 发送到 me@hotmail.com)通常会失败,因为服务器最终会被滥用并最终进入黑名单,然后通常也会阻止正确的邮件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.