Link to home
Start Free TrialLog in
Avatar of riceman0
riceman0

asked on

Access SMTP server with authentication

(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!.
ASKER CERTIFIED SOLUTION
Avatar of Rahul Singh
Rahul Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lbertacco
lbertacco

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
Avatar of riceman0

ASKER

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.)
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?
yesssss there implementation is diffrent....
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.
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