• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2559
  • Last Modified:

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!.
0
riceman0
Asked:
riceman0
  • 5
  • 4
  • 2
1 Solution
 
aatrish2001Commented:
here is smtp server of gmail

gmail-smtp-in.l.google.com

try this

telnet   gmail-smtp-in.l.google.com   25

helo google.com

MAIL FROM:<...........>

RCPT  TO:<...........>

DATA

To:
Date:
From:
Subject:
Message:
then type   .

then send quit to close the socket    (just implement these things in c++) cheers:-)

0
 
lbertaccoCommented:
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
0
 
riceman0Author Commented:
Woah, aatrish, that worked!  That's a different gmail server than I was using.  Why doesn't it require SSL???
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
lbertaccoCommented:
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.
0
 
riceman0Author Commented:
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.)
0
 
aatrish2001Commented:
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   :-)
































































0
 
riceman0Author Commented:
What do you mean "use any corporate ID"?

You mean like smtp.ibm.com?
0
 
aatrish2001Commented:
yesssss there implementation is diffrent....
0
 
aatrish2001Commented:
genrally comps purchase space on web from other company so

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

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.
0
 
aatrish2001Commented:
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
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now