We help IT Professionals succeed at work.

Access SMTP server with authentication

riceman0 asked
Last Modified: 2012-05-05
(Trying again because not making much progress)

Okay, I've got an older microsoft VC++ 6.0 program that works great, it's a home automation program that sends me an email at work at certain times.

However, I'd like to switch smtp servers to my gmail account, but smtp.gmail.com requires some sort of encryption (I think it's TLS, because when I telnet in to send an email I get a "must issue a STARTTLS command first z52ss97610").  I am sending my email using sockets with this server, so I have to figure out what commands to send the server (I think I'm supposed to process that z52ss976 into a hashed value, with my password probably, and send it back?).  Does anyone have a specific blow-by-blow about how to negotiate with these email servers?  Or some sample code that handles this?

Previously I was using the popular FastSMTP class, which works great but isn't built to handle this type of authentication.

(By the way this works perfectly and transparently with my .NET programs, I can send an email programmatically using my gmail account, so I know it's possible, it's just that the encoding -- MD5? -- is performed automatically by the .NET objects.  In MFC I have to do this manually by sending the right data using sockets, and I just don't know how to calculate the right responses and what to send.  I do NOT want to convert this program to .NET, this should be very do-able in MFC)

I've been working three angles, none easy:

a) http://en.wikipedia.org/wiki/Secure_Sockets_Layer

gives a lot of detail on the data and sequence.  This would be writing it from scratch, and assuming that this really tells you everything.  A lot of work.

b) http://www.codeproject.com/internet/casyncsocketex.asp

which is a project that extends an async socket with SSL.  My first problem is that I don;t how to apply this yet, gmail requires a connection, and then a STARTTLS command, then TLS handshaking.  Not sure this gives you that much control (although I try to figure it out by inspection and it seems to call all of that stuff out of the openssl library, thus...)

c) http://en.wikipedia.org/wiki/Openssl

which is an open source ssl/tls library, which could fit my bill but haven't even scratched the surface yet.

Any is a pain in the butt, anybody have anything to move me along in any direction?  Thanks!.
Watch Question

Project Managet
Unlock this solution and get a sample of our free trial.
(No credit card required)
If your purpose is to send mail through gmail and not write an ssmtp client, than you can use stunnel to provide the tls layer. You just connect normally (no tls) to a local port that stunnel listen on and it tunnels data to the destination smtp server using a tls connection. See e.g. http://spampal.sanesecurity.com/manual_eng/servers/stunnel/stunnel.htm#sconfig21


Woah, aatrish, that worked!  That's a different gmail server than I was using.  Why doesn't it require SSL???
Well, gmail-smtp-in.l.google.com is the inbound MX mail server for the gmail.com domain. It can't require TLS otherwise gmail users couldn't receive mail from MTAs that don't use TLS.
But you can use it ONLY to send emails to ...@gmail.com.
It's different than the outbound smtp server that gmail users are supposed to useto send mail outside (smtp.gmail.com). This one lets you send email to ANY domain (after authentication) AND email sent this way ends up in your Sent folder.


Okay, figuring out whether that will fit my bill...

(By the way, re-reading my question, I wasn't claiming to be a guru on this question, I was trying to say I NEED a guru on this question.  Still getting used to new scheme.)
Rahul SinghProject Managet

well rice man there is the smtp server for each and every mail like gmail which dont require authentication,
but if you use any corporate ID they wont work like that   :-)


What do you mean "use any corporate ID"?

You mean like smtp.ibm.com?
Rahul SinghProject Managet

yesssss there implementation is diffrent....
Rahul SinghProject Managet

genrally comps purchase space on web from other company so

its not necessart the smtp server will contain the name of company also:-)



It sounds like you're telling me something about the landscape of the internet.  I don't know much about that, definitely  Can you summarize it for me?  Thanks.
Rahul SinghProject Managet

well brother.

suppose if u want to create a web addrese then u need web hosting space on the net(several company provide that space to web) depending upon size and money u can ask them for mail id( of course ur corporate id) and the space per mail id and lots of other customization since its highly taiolred depending on the need and space involved
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.