Home
Posted By: Virtual1 pushing email directly through gmail - 06/07/10 03:38 AM
OK this is going to leave a few behind immediately but here goes:

openssl s_client -connect smtp.gmail.com:587 -starttls smtp
ehlo user
auth plain (removed)
mail from: <myusername@gmail.com>
rcpt to: < myusername@gmail.com>
data
test
.

and when I do the dot . alone on the line it's supposed to accept and deliver it. but it just sits there, forever accepting line after line of input. If I ctrl-c out to stop it, it does not send. Actual interaction:

235 2.7.0 Accepted
mail from: < myusername@gmail.com>
250 2.1.0 OK r12sm18803824ixi.14
rcpt to: < myusername@gmail.com>
250 2.1.5 OK r12sm18803824ixi.14
data
354 Go ahead r12sm18803824ixi.14
From: myusername@gmail.com
To: myusername@gmail.com
Subject: this is a test message

This is a test message
this is only a test
.

.
stop
^R


and it can't be made to accept the message and send. I'm not alone:

http://in.answers.yahoo.com/question/index?qid=20100428073821AATBWdc

He didn't get any help either. FWIW I am trying to get authenticated relaying going on some of my bash scripts so they can send email out, even when there's no local SMTP server that accepts relaying. I have it working fine (using "expect") for non ssl, but I wanted to get the ssl variant working because I want to support gmail specifically and they only do ssl smtp. This may be a problem only with gmail. (I've already fought through some other weird quirks, like the "rcpt to" must be LOWER case, others don't care) It's funny gmail is the only one I've ran into that doesn't explicitly say to end the message with a period on an empty line, they just say "go ahead".

(fyi the auth plain format is the uuencode of chr(0)USERNAMEchr(0)PASSWORD )
Posted By: tacit Re: pushing email directly through gmail - 06/07/10 11:50 AM
Google expects CR LF . CR LF

Is it possible that when you're pressing the Return key, it's not generating CR LF? I seem to recall that on Macs it just generates an LF.
Posted By: Virtual1 Re: pushing email directly through gmail - 06/07/10 02:40 PM

expect "3?? *" {
} "5?? *" {
exit
} "4?? *" {
exit
}
send "From: $got_from\r"
send "To: $got_to\r"
send "Subject: $got_sub\r\r"
send "$got_msg"
send "\r\n.\r\n"
expect "2?? *" {
} "5?? *" {
exit
} "4?? *" {
exit
}
send "QUIT\r"
exit

\r\n instead of just \r does not help frown

session:

mail from: <myaddress@gmail.com>
250 2.1.0 OK f1sm21147552ixg.3
rcpt to: < myaddress@vftp.net>
250 2.1.5 OK f1sm21147552ixg.3
data
354 Go ahead f1sm21147552ixg.3
From: myaddress@gmail.com
To: myaddress@vftp.net
Subject: this is a test message

this is only a test

.

logout (ctrl-c pressed after some time)


Here's one that works on my non ssl mailserver:

MAIL FROM: < myaddress@me.com>
250 2.5.0 Address Ok.
RCPT TO: < myaddress@vftp.net>
250 2.1.5 myaddress@vftp.net OK.
DATA
354 Enter mail, end with a single ".".
From: myaddress@me.com
To: myaddress@vftp.net
Subject: this is a test message

this is only a test
.
250 2.5.0 Ok.
logout

So I thought I'd test with me.com's ssl on 587 with this:
openssl s_client -connect smtp.me.com:587 -starttls smtp

and it hangs, apparently unable to exchange certificates....

when I try to set it up that way in mail, THAT doesn't even work. It sets up, connection doctor tests it good, and yet when i try to send it gets an odd error:

"sending the message content to the server failed"

maybe my very bad luck and mobileme's ssl smtp is down today

...

well, 25 minutes on applecare phone and he's stumped. transferring to mobileme chat support. pity me.
Posted By: tacit Re: pushing email directly through gmail - 06/07/10 08:58 PM
Hmm. Google's Gmail developer docs don't seem to help much; and there are example PHP and ASP scripts that seem to work. They all use /r/n./r/n to terminate the message data.

Gmail's SMTP servers don't accept data connections from IP addresses without the proper rDNS entries; could that be the problem?
Posted By: Virtual1 Re: pushing email directly through gmail - 06/10/10 01:23 AM
Finally got it. There are a lot of little minor details to getting it to work but I think I have it reliable now.

http://vftp.net/virtual1/temp/MFIF/gmail_auth_relay/

by no means fully optimized but first functional draft.
© FineTunedMac