2014-02-16 27 views
0

我有一個問題,當我上傳一個應用程序到Web。我想發送郵件給幾個用戶,但它不起作用,但是當我發送本地主機正常工作。不要發送郵件asp.net應用程序託管只在localhost

這裏是我的代碼來發送郵件

System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage(); 
correo.To.Add(mail_usuario); 
correo.Body = cuerpomensaje; 
correo.BodyEncoding = System.Text.Encoding.UTF8; 
correo.Priority = System.Net.Mail.MailPriority.Normal; 
correo.IsBodyHtml = true;//false tested too. 

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); 
smtp.Host = "mail.cscdecision.com"; 
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "IDPass"); 
//smtp.Credentials = new System.Net.NetworkCredential(sMailEnvioEmpresaServicio , sClaveEmpresaServicio); 
smtp.EnableSsl = true; 

smtp.SendAsync(correo, null); 
//smtp.Send(correo); 

的錯誤是:「無法發送給所有收件人」

爲什麼在本地主機的作品,並在主機沒有?

Error: System.Net.Mail.SmtpFailedRecipientsException: Unable to send to all recipients. 
System.Net.Mail.SmtpFailedRecipientException: The mailbox is unavailable. 
The server response was: 5.7.1 <[email protected]> Access to <[email protected]> not allowed 
+0

您是否收到錯誤?這個應用程序在哪裏部署? – HTX9

+0

錯誤是「無法發送配方」。主持人我不知道,但程序的早期版本正常工作。 – Alex

+0

當我使用smtp.Send(correo)給我那個錯誤,但與smtp.SendAsync(相關)沒有發生 – Alex

回答

0

你指定了郵件服務器的端口嗎?

即smtp.port = 25(或不同的端口用於SSL)

它可能是您的主機阻止你正在使用的端口。

+0

否我沒有指定端口。 我必須使用什麼? – Alex

+0

錯誤:System.Net.Mail.SmtpFailedRecipientsException:無法發送給所有收件人。 System.Net.Mail.SmtpFailedRecipientException:郵箱不可用。 服務器響應爲:5.7.1 <[email protected]>不允許訪問<[email protected]> – Alex

0

您是否發送到相同的域名?如果是,那麼您必須配置該域具有不是本地的遠程郵件服務器。

這在cpanel主機中很常見。當域名有遠程郵件服務器時