开发者

What am I missing? My app can send e-mail via gmail on my dev box, but not on my server

开发者 https://www.devze.com 2022-12-13 11:20 出处:网络
My config files are identical, except for connection strings. I\'m using IIS on both machines I elevated the IIS user on the server to ensure it\'s not a permissions issue
  • My config files are identical, except for connection strings.
  • I'm using IIS on both machines
  • I elevated the IIS user on the server to ensure it's not a permissions issue
  • No exceptions are thrown on my server where the e-mails are not being sent开发者_StackOverflow社区
  • I know the gmail configs are correct because I can send e-mails from my dev box.
  • Windows firewall is off and the network firewall is not blocking outbound ports.

What else should I look for?

IIS 7 on Win2k8, using ASP.NET w/ C#

SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Send(fromAddress, toAddress, subject, body);


Gmail requires authentication from the SMTP client, so you need to fill in the Credentials property on your SmtpClient instance as shown here.

That doesn't explain why it works from your development box (unless the POP3 method still works) but it would explain why the code you have shown doesn't work.


wrap smtpClient.Send(fromAddress, toAddress, subject, body); inside a try catch statment and see what the exception is

0

精彩评论

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