Mailbox unavailable. The server response was: 5.7.1 Unable to relay for (email address).


在发送email时得到这个异常,
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for (email address).

解决办法是添加一句代码:
client.DeliveryMethod  =  SmtpDeliveryMethod.PickupDirectoryFromIis;
新代码如下:
            MailMessage message  =   new  MailMessage(from, to, subject, body);
            SmtpClient client 
=   new  SmtpClient();
            client.DeliveryMethod 
=  SmtpDeliveryMethod.PickupDirectoryFromIis;

            message.IsBodyHtml 
=   true ;
            client.Send(message);

发信正常了:)

你可能感兴趣的:(Mailbox unavailable. The server response was: 5.7.1 Unable to relay for (email address).)