SMTP Mail issues

B

Brett Porter

Hi,

My ASP.Net applications frequently make use of the System.Web.Mail
namespace to send emails. I have set SmtpMail.SmtpServer = "localhost"
and the emails send out fine UNTIL an email is sent to the same
address as the server / website address i.e.

If the web address is www.servername.com an email sent using SMTPMail
to (e-mail address removed) effectively does not reach the destination.

The reason for this is that the SMTP Server is not the same server
that the website is hosted on but requires authentication so I cannot
simply change the SmtpMail.SmtpServer property as authentication fails
and the email is not sent. In IIS the mail root directory seems to
have created an email account where all the emails sent from the site
are delivered (where the email address matches the server / web
address) however because the server is not the SMTP server these
emails are never collected.

So my question is: In IIS is there any way to turn off the local
delivery of emails if they have the same address as the server
address?
 
B

Bill

I am not 100% sure but I think you will need to change the host name to
something different then what your actual mail server host name is. If they
are the same there is no way for it to relay it to the correct server. If
that doesn't work you should be able to switch servers depending on the
domain. This is just a work around you can use to get it working.

This should work:

if(Address.EndsWith("yourdomain.com"))
SmtpMail.SmtpServer = "mail.yourdomain.com"; //Your mail server
else
SmtpMail.SmtpServer = "localhost";
 
B

Brett Porter

Hi Bill,

Yes, good idea, unfortunately the actual SMTP mail server requires
authentication that I haven't been able to do within the ASP.Net code.

Brett
 
B

Bill

When sending to the local domain you do not need to use authentication.
Only when relaying outside of the local domain. That is why sending to your
mail server for local address should work without the authentication.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top