Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have gmail for our corporate email provider.

I want to be able to send mail through smtp.gmail.com from ASP.NET. I have managed to do this just fine - and it has the benefit of all sent items appearing in the correct sent items folder within gmail. However it can take up to 2-3 seconds to make a connection to smtp.gmail.com. Occasionally it will even fail completely. Since this is ASP.NET app I need to be able to reliably send email. I don't want to have to go and create some email daemon of my own - i just want to rely on SMTP.

I've tried with the Virtual SMTP Server on IIS6 but haven't been able to get it to work. An active current session is shown for up to a minute and then it disappears.

Do I need to use something like sendmail to do this - or some other free SMTP relay that gives me better control? I even found a sourceforge project called 'Gmail SMTP Relay' - and the hosted server we're using has installed - which has its own SMTP server.

I'd prefer something graphical - and most of all I'd prefer the Microsoft SMTP server becasue I already have it installed.

share|improve this question

2 Answers 2

I fought with this for a few weeks. Here are the settings that I'm using on 3 ASP.NET websites that use SMTP gateway to send their emails:

Address: smtp.gmail.com Port: 587

1) The port is very important. You may have to enter it like smtp.gmail.com:587 in your SMTP server. I haven't touched Microsoft SMTP in years, so I can't remember what the setup screen looks like.

2) Make sure to enable SSL for SMTP, as gmail requires it.

3) SMTP Authentication should be set to Basic.

4) Make sure that you are using an actual email and not an email alias to authenticate. This one gave me lot of trouble.

This is how I got it working.

share|improve this answer
    
which SMTP gateway are you using? thats the main thing I don't understand how to configure –  Simon Jan 3 '10 at 8:59
    
i already have these settings in my web.config. i need to know how to use an intermediary SMTP server to relay them –  Simon Jan 3 '10 at 9:00
up vote 3 down vote accepted

Found this explanation here of exactly what I needed (when using IIS) :

http://fmuntean.wordpress.com/2008/10/26/how-to-configure-iis-smtp-server-to-forward-emails-using-a-gmail-account/

I am sending mail using this C# code

var client  = new SmtpClient("127.0.0.1", 587);
client.EnableSsl = false;

Note: the communication between my C# app and my local SMTP server is not encrypted (hence the EnableSsl=false) - but the communication between my SMTP server and GMAIL is encrypted (see the linked doc for more).

Important tip: If you are using the Microsoft SMTP client to relay mail make sure you don't have any domains in the 'Default SMTP Virtual Server > Domains' list. if so any email addressed to those domains will end up in C:\Inetpub\mailroot\Drop - which is probably not what you want in this instance. I just renamed mydomain.com to (literally) example.com after having problems with outgoing mail not actually going out.

share|improve this answer
    
Ahh, ok. I see what you meant now. You wanted to use your own SMTP server as your local point, and Gmail's servers as the actual email sender. –  Hector Sosa Jr Jan 5 '10 at 18:56
    
right - basically its about speed. it takes a few ms to send to my local server vs. up to 2-3 seconds to send to gmail - which may even fail –  Simon Jan 6 '10 at 23:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.