SMTP: cannot send email from windows server 2012

风格不统一 提交于 2019-12-24 09:39:40

问题


I have strictly followed this tutorial in order to configure SMTP server on Windows Server 2012 R2 by usng IIS 6. In fact, if I create a correct formatted file email.txt inside

C:\inetpub\mailroot\Pickup

with From, To and Subject fields, it is dispatched immediately to the destination email address with the correct sender. Then, I have a framework generating my ASP NET C# web application ad when it tried to send an email with:

 IDMailer v_M1 = null;
 v_M1 = (IDMailer)new IDMailer();
 v_M1.FromAddress = (new IDVariant("allegretti@er-go.it")).stringValue();
 v_M1.AddToAddress((new IDVariant("lorenzo.vinci@conservice.it")).stringValue()); 
 v_M1.Subject = (new IDVariant("prova")).stringValue();
 v_M1.HTMLBody = (new IDVariant("<b>ciao!</b>")).stringValue();
 try
 {
   v_M1.SendMail();
 }
 catch (Exception e3)
 {
   MainFrm.set_AlertMessage(new IDVariant(e3.Message)); 
 }

then I have an error in sending the email which fails. I have tried also both the following settings in the application pool of my web application:

and they both fail with these error messages:

Thursday, October 6, 2016 - 5:38:09 PM
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at com.progamma.IDMailer.SendMail()
 DTT_LEVEL=5
 DTT_MSGLEVEL=3
 DTT_LEVEL=5
 DTT_MSGLEVEL=3
 Failure sending mail.
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at com.progamma.IDMailer.SendMail()
   The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

   at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
   at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
   at System.Web.Mail.SmtpMail.Send(MailMessage message)
   at com.progamma.IDMailer.SendMailSSL()
--------------------------------------------------------------------
Thursday, October 6, 2016 - 5:38:25 PM
Failure sending mail.
 at System.Net.Mail.SmtpClient.Send(MailMessage message)
 at com.progamma.IDMailer.SendMail()

I have no idea why this happens but I really need to correctly set up a SMTP server in our Windows Server. I had tried to use Google smtp server as realy and it was ok but it did not allow us to set an arbitrary sender email address but only the one of the account used to connect to gmail smtp server. That's why I need my SMTP server because sender anddress will vary according to the user logging into the web application. How can I solve this? Maybe does this happen because the web applicaion is installed inside drive D (which has its own pickup emailroot directories) instead of C drive?

来源:https://stackoverflow.com/questions/39900748/smtp-cannot-send-email-from-windows-server-2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!