开发者

Code Conversion from Classic ASP to ASP.NET

My client have a classic ASP site on his dedicated server on which he sends mail using IIS (Its working properly there).

Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "localhost" ' Specify a valid SMTP server
Mail.Username = "mail@site.com"
Mail.Password = "password"
Mail.From = "info@site.com"

I tried converting this to ASP.NET like this.

SmtpClient smtp = new SmtpClient();
smtp.Host = "localhost";
smtp.Port = 25;
//smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("mail@site.开发者_如何学Gocom", "password");

smtp.Send(message);

But this doesn't work. Its almost legacy app without any error logger / monitoring and I cannot debug the code on online server.

What is wrong with my code?


This seems like a permissions issue. Check this thread for details.


You might want to check to see if port 25 is being blocked, as shown in http://kb.siteground.com/article/How_to_check_whether_SMTP_port_25_is_blocked.html


Make sure the pickup directory is being monitored by your local SMTP server if you use this method:

smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

If it is not then the messages will remain there without being sent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜