Page 1 of 1

TSmtp, gmail, authentication

Posted: Fri Mar 08, 2013 5:42 pm
by Luis Krause
Hello all, long time since I've been around.

Back in the day I made several enhancements to TSmtp class and others
chimed in to implement authentication.

Until now I've never had a need for authentication, but now I do and
it isn't working quite right with gmail.

Here's the info I was provided:

smtp.gmail.com
Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465

So I do

oMail := TSmtp():New( cHost, if( lAuth, 587, 25 ), lAuth, cUser, cPass ) // [jlalin], IBTC

that is I set the port to 587 I get as far as the log shows, but I don't know where
does the SSL port 465 come into play and where do you use it:

02/04/13 16:08:01: Connect Socket handle: 552 WSA Error: 0
02/04/13 16:08:01: Write Socket handle: 552 WSA Error: 0
02/04/13 16:08:01: Read Socket handle: 552 WSA Error: 0
02/04/13 16:08:01: 220 mx.google.com ESMTP bg10sm13836353igc.6 - gsmtp

02/04/13 16:08:01: HELO smtp-client

02/04/13 16:08:01: AUTH LOGIN

02/04/13 16:08:01: Read Socket handle: 552 WSA Error: 0
02/04/13 16:08:01: 250 mx.google.com at your service

02/04/13 16:08:01: Read Socket handle: 552 WSA Error: 0
02/04/13 16:08:01: 530 5.7.0 Must issue a STARTTLS command first. bg10sm13836353igc.6 - gsmtp

02/04/13 16:18:01: Read Socket handle: 552 WSA Error: 0
02/04/13 16:18:01: 451 4.4.2 Timeout - closing connection. bg10sm13836353igc.6 - gsmtp

02/04/13 16:18:01: Close Socket handle: 552 WSA Error: 0


It's clear that the gmail server is expecting some new call after
530 5.7.0 Must issue a STARTTLS command first. bg10sm13836353igc.6 - gsmtp

but I don't know where/how to make it work.

Any suggestions are appreciated.

Re: TSmtp, gmail, authentication

Posted: Fri Mar 08, 2013 6:26 pm
by ADutheil
My suggestion is to switch to hb_sendmail function. I´ve been using it successfully for a while with gmail accounts.

Re: TSmtp, gmail, authentication

Posted: Fri Mar 08, 2013 10:12 pm
by reinaldocrespo
Luis;

Hi. The problem is that TSMTP with its authentication modifications, will authenticate by sending username and password as mime encoded strings. Mail servers such as gmail, work over ssl. TSMTP is not using ssl.

I think it is possible to send mail over ssl by using hb_sendMail() + linking tip.lib + tipssl.lib + libeay32.lib + ssleay32.lib. You will find information on how to build these libs on the xharbour ng. I'm currently using ssl to consume https webservices and I can tell you, it works!

I would love to see fw tsmtp class modified to use ssl. hb_sendmail() source can help.

Hope that gets you started on the right direction.


Reinaldo.

Re: TSmtp, gmail, authentication

Posted: Sat Mar 09, 2013 2:05 am
by Luis Krause
Reinaldo, ADutheil

Thanks for the info on hb_sendmail().
I'll have to review it and figure it out.
And yes, if only TSmtp supported SSL.

Regards,