With the following settings I have not been able to send mails from local PC. Having searched stack overflow for many responses -
- I tried swapping host from smtpout.secureserver.net to relay-hosting.secureserver.net. Which didn't help. (Probably because relay-hosting has to be used when hosting on godaddy server) My host is windows azure service..
- I read on SO that defaultCredentials & enableSSL is mutually exclusive. Please suggest.
- Port 25 may be blocked by several ISP, so as an alternative port 80 could be used for sending mail using http.
- System.net.Mail doesn't support godaddy's 465 port for https.
Having tried all these possibilities, I end up with either of the two errors -
- Failure sending Mail - Unable to connect with remote server.
- The SMTP server requires a secure connection or the client was not authenticated.
Question 1. Please suggest precisely, what piece of configuration do I need to use godaddy smtp server from Windows Azure service?
From localhost I am trying to enable self-signed certificate, as suggested by Scott, here..
Question 2. specifying from address in web.config, seems redundant, since in MailMessage we're bound to enter from address once again. What is its purpose ?
What the easiest way to configure Azure to configure IIS to use azure service to
private void SendMail(MailMessage msg)
{
try
{
var smtp = new SmtpClient();
smtp.Send(msg);
}
catch (SmtpFailedRecipientException exFailed)
{
lblExSendMail.Text = exFailed.Message;
}
}
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="xyz@xyz.com">
<network host="smtpout.secureserver.net" port="80" userName="xyz@xyz.com" password="xyz-password" />
</smtp>
</mailSettings>
Sending email from Windows Azure Application using 3rd party SMTP server does not need any special configuration on either parties, Windows Azure or 3rd party SMTP server. Most of SMTP server are set to use port 25 which is easiest way to send email from Windows Azure and GoDaddy SMTP server is also set to use port 25 so you sure can do it easily. No SSL/certifcate configuration is needed on any side.
Following code snippet is the simplest code you can use either in C# app or in Windows Azure directly without any configuration eith goDaddy SMTP service:
That is so simple:
You must focus on smtp host, port, ssl... Change smtp host to: relay-hosting.secureserver.net And DELETE port and ssl, thats all... Do not use smtp port and smtp ssl true or false
That works on Godaddy Windows Host on target Framework 4.0
Ans 1. Port 80 instead of using 25 did work for me for sending mails using http channel. This worked for both local and Windows Azure. Prevent yourself from specifying anything else in network element smtp, apart from host, port=80, userName and password-->for http.
Ans 2. From attribute of smtp element in web.config is used by parameterless constructor of MailMessage. This is particularly useful when you are going to send mail by common email address.