views:

27

answers:

1

I'm trying to send an email via asp.net mvc2, and all works well on our companies mail server.

However, we're looking to switch to using our client's BPOS account. This works fine locally, but when deployed to azure, we're getting some timeout errors.

Can anybody confirm I have the following correct?

SmtpClient smtp = new SmtpClient("Smtp.mail.emea.microsoftonline.com");
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("BPOS-EMAIL", "BPOS-PASSWORD");

In addition, does anyone know why it works when run locally, but not when run on azure?

+1  A: 

Are you running the web role in Full Trust? By default, SmtpClient is going to execute under ASP Medium trust. Under that model, Smtp is only allowed to communicate over port 25 in Azure.

If you need to use the SmtpClient.Port property, you'll need to have the role run under full trust.

That's achieved by setting the enableNativeCodeExecution attribute on the Web Role in the Service Definition.

<WebRole name="WebRole1" enableNativeCodeExecution="true">

Thats the only thing I can think it might be. If that's not it and you can post error logs, that may show more details as to the problem.

Taylor
Worked Perfectly. Thank you!
Once_functional