Sending an email to the local domain

后端 未结 3 1103
孤街浪徒
孤街浪徒 2021-01-13 17:42

I\'ve got a simple method to send emails from the website:

... // local vars
using (var mail = new MailMessage(from, sendTo))
{
    using (var smtp = new Smt         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 18:09

    I think it is almost certainly a mail server configuration issue.

    According to the SmptClient.Send() Documentation any incorrect configuration on your end (Host, Credentials, Port, SSL, Firewall, Anti-Virus etc) should throw an InvalidOperationException or a SmtpException.

    The fact that you can send external mail using the same code and config - which means that you have connectivity to the mail server also very strongly suggests that the problem lies downstream.

    I have worked at companies in the past that had different mail servers for internal and external mail delivery.

    It could be worth considering what Credentials are being used for the message. Perhaps you have a rule which only allows members of a group (All Company or something like that) to send mail to internals addresses. You could check this by using your real domain credentials (and removing them after the test)

    smtp.Credentials = new NetworkCredential("your.username", "your.password");
    

    Either way if no exception is generated the message should have been received on the mail server, and it is up to that server to determine delivery.

提交回复
热议问题