I hope this is the appropriate place to ask this question - I couldn't find any mailing lists specific to SMTP. I couldn't find where to subscribe to this mailing list so you may have to include my address in the reply.
I'm using the standard SMTP library that comes with Emacs (I am using Carbon Emacs 22.1). The connection requires SSL and password authentication. Whenever I try to send a message, Emacs simply freezes up. Here are my connection settings; I have tried both gnutls-cli and starttls (using the variable which toggles which one to use, I forget the name of it).
I'm sure my credentials, server, and port are correct, and that the server is fine. I don't get anything in the SMTP trace buffer. I suppose I should figure out how to use edebug, which I will attempt later on.
Could one of my libraries be out of date? gnutls-cli (I have version 2.3.1), or smtpmail.el, or something else?
I'm not sure if it's still related with your problem but... AFAIK, you'll also need to set smtpmail-auth-credentials variable too. (BTW, assuming you configured starttls-gnutls-program and starttls-extra- arguments appropriately.)
> I'm sure my credentials, server, and port are correct, and that the > server is fine. I don't get anything in the SMTP trace buffer. I > suppose I should figure out how to use edebug, which I will attempt > later on.
I dunno about edebug (I should check it out too), but you can simply get a rough idea about the problem via some kind of strace tool. (Or listen communication going on on related ports via some middleware.)
> I'm using the standard SMTP library that comes with Emacs (I am using > Carbon Emacs 22.1). The connection requires SSL and password > authentication. Whenever I try to send a message, Emacs simply > freezes up. Here are my connection settings; I have tried both > gnutls-cli and starttls (using the variable which toggles which one to > use, I forget the name of it).
> I'm sure my credentials, server, and port are correct, and that the > server is fine. I don't get anything in the SMTP trace buffer. I > suppose I should figure out how to use edebug, which I will attempt > later on.
> Could one of my libraries be out of date? gnutls-cli (I have version > 2.3.1), or smtpmail.el, or something else?
I have a similar or perhaps the same problem. I use the same type of settings as you do. How long did you wait after Emacs "froze up". In my case, it "unfreezes" after 20 minutes and the SMTP trace buffer shows this:
Process SMTP finished 454 TLS connection failed: timed out (#4.3.0) - Peer has closed the GNUTLS connection QUIT
This is reproducible. I can access the same SMTP server using KMail, so I assume, like you, that my problem is somewhere in smtpmail.el or gnutls-cli (I don't have starttls), perhaps a wrong setting. It would be nice if someone can solve this one; I haven't been able to.
Stephen Berman <Stephen.Ber...@gmx.net> writes: > I have a similar or perhaps the same problem. I use the same type of > settings as you do. How long did you wait after Emacs "froze up". In > my case, it "unfreezes" after 20 minutes and the SMTP trace buffer shows > this:
> Process SMTP finished > 454 TLS connection failed: timed out (#4.3.0) > - Peer has closed the GNUTLS connection > QUIT
Could it be that the SMTP server does ssmtp (usually on port 465) instead of SMTP+STARTTLS? Do you see a greeting message from the server when you connect to it with telnet?
On Wed, 05 Mar 2008 13:54:44 +0100 David <de...@arcor.de> wrote:
> Stephen Berman <Stephen.Ber...@gmx.net> writes: >> I have a similar or perhaps the same problem. I use the same type of >> settings as you do. How long did you wait after Emacs "froze up". In >> my case, it "unfreezes" after 20 minutes and the SMTP trace buffer shows >> this:
>> Process SMTP finished >> 454 TLS connection failed: timed out (#4.3.0) >> - Peer has closed the GNUTLS connection >> QUIT
> Could it be that the SMTP server does ssmtp (usually on port 465) > instead of SMTP+STARTTLS?
The does indeed use port 465 (and I set smtpmail-smtp-service to 465). Are you saying that smtpmail.el does not support ssmtp?
> Do you see a greeting message from the server > when you connect to it with telnet?
No:
$ telnet mail.myprovider.com Trying 123.456.78.9... telnet: connect to address 123.456.78.9: Connection timed out
I know nothing about ssmtp. Assuming the server does use it, is there a way to access it from Gnus?
Stephen Berman <Stephen.Ber...@gmx.net> writes: >> Could it be that the SMTP server does ssmtp (usually on port 465) >> instead of SMTP+STARTTLS?
> The does indeed use port 465 (and I set smtpmail-smtp-service to 465). > Are you saying that smtpmail.el does not support ssmtp?
I don't know, but I don't see any option to activate it.
>> Do you see a greeting message from the server >> when you connect to it with telnet?
> No:
> $ telnet mail.myprovider.com > Trying 123.456.78.9... > telnet: connect to address 123.456.78.9: Connection timed out
I should have mentioned that you have to try the port you want to connect to, i.e.
telnet mail.myprovider.com 465
> I know nothing about ssmtp. Assuming the server does use it, is there a > way to access it from Gnus?
ssmtp simply means that the TLS connection is established immediately, whereas SMTP+STARTTLS first does the EHLO-stuff in clear text and the TLS connection is only established if the server advertises it to the client. AFAIK, ssmtp is more or less deprecated and servers support it only because of MS Outlook. Nowadays, TLS connections are usually done on the standard port 25, so this is the first you should try. You can test this by using a tool like 'swaks' or simply with telnet:
> Stephen Berman <Stephen.Ber...@gmx.net> writes: >>> Could it be that the SMTP server does ssmtp (usually on port 465) >>> instead of SMTP+STARTTLS?
>> The does indeed use port 465 (and I set smtpmail-smtp-service to 465). >> Are you saying that smtpmail.el does not support ssmtp?
> I don't know, but I don't see any option to activate it.
>>> Do you see a greeting message from the server >>> when you connect to it with telnet?
>> No:
>> $ telnet mail.myprovider.com >> Trying 123.456.78.9... >> telnet: connect to address 123.456.78.9: Connection timed out
> I should have mentioned that you have to try the port you want to > connect to, i.e.
> telnet mail.myprovider.com 465
With this I get the same results as with smtpmail.el:
$ telnet mail.myprovider.com 465 Trying 123.456.78.9... Connected to mail.myprovider.com. Escape character is '^]'. 454 TLS connection failed: timed out (#4.3.0) Connection closed by foreign host.
>> I know nothing about ssmtp. Assuming the server does use it, is there a >> way to access it from Gnus?
> ssmtp simply means that the TLS connection is established immediately, > whereas SMTP+STARTTLS first does the EHLO-stuff in clear text and the > TLS connection is only established if the server advertises it to the > client. AFAIK, ssmtp is more or less deprecated and servers support it > only because of MS Outlook. Nowadays, TLS connections are usually done on > the standard port 25, so this is the first you should try. You can test > this by using a tool like 'swaks' or simply with telnet:
> telnet mail.myprovider.com 25
> and after the greeting you type something like
> EHLO my.address.com
> and if the server answers
> 250-STARTTLS
> it should work with smtpmail.el.
Telnetting to port 25 just times out as above with no port. I also tried swaks:
$ swaks -s mail.myprovider.com To: stephen.ber...@gmx.net === Trying mail.myprovider.com:25... *** Error connecting 0.0.0.0 to mail.myprovider.com:25: *** IO::Socket::INET: connect: timeout $ swaks -s mail.myprovider.com -p 465 To: stephen.ber...@gmx.net === Trying mail.myprovider.com:465... === Connected to mail.myprovider.com. <** Timeout (30 secs) waiting for server response -> QUIT <** Timeout (30 secs) waiting for server response === Connection closed with remote host.
Again, I can send and receive mail via this server using KMail, which I set up simply by providing the server's FQDN and my user name (KMail figured out the port and authorization method and prompts for my password). So I expected (and still hope) there's some way to access it with Gnus.
> Again, I can send and receive mail via this server using KMail, which I > set up simply by providing the server's FQDN and my user name (KMail > figured out the port and authorization method and prompts for my > password). So I expected (and still hope) there's some way to access it > with Gnus.
If the above swaks command works, you can use an external tool like stunnel to set up the SSL connection. If you have root on the machine, you can use stunnel like this
You should then be able to send mails through your localhost on port 2000. Note that the '-f' option lets stunnel run in the foreground for testing purposes. If it works, you can omit this option and let stunnel run as daemon.
>> Again, I can send and receive mail via this server using KMail, which I >> set up simply by providing the server's FQDN and my user name (KMail >> figured out the port and authorization method and prompts for my >> password). So I expected (and still hope) there's some way to access it >> with Gnus.
> If the above swaks command works, you can use an external tool like > stunnel to set up the SSL connection. If you have root on the machine, > you can use stunnel like this
> You should then be able to send mails through your localhost on port > 2000. Note that the '-f' option lets stunnel run in the foreground for > testing purposes. If it works, you can omit this option and let stunnel > run as daemon.
I don't have root access to the machine that hosts the mail server, or do you mean the machine I use to send mail via the server? If the latter, how would I make Gnus aware of the tunnel?
I instrumented smtpmail.el for Edebug and stepped through the code as I tried to send a mail. The "freeze" occurred in smtpmail-read-response at the call to accept-process-output, which is from the Emacs C code. I assume this means gnutls is not providing the server what it needs, so it just waits until it hits the timeout, but I don't know how to proceed to find out what is going wrong.
>> If the above swaks command works, you can use an external tool like >> stunnel to set up the SSL connection. If you have root on the machine, >> you can use stunnel like this
>> You should then be able to send mails through your localhost on port >> 2000. Note that the '-f' option lets stunnel run in the foreground for >> testing purposes. If it works, you can omit this option and let stunnel >> run as daemon.
> I don't have root access to the machine that hosts the mail server, or > do you mean the machine I use to send mail via the server?
The latter.
> If the latter, how would I make Gnus aware of the tunnel?
Just point smptmail.el to your localhost on port 2000 (or whatever you're writing in the above stunnel command).
> I instrumented smtpmail.el for Edebug and stepped through the code as I > tried to send a mail. The "freeze" occurred in smtpmail-read-response > at the call to accept-process-output, which is from the Emacs C code. I > assume this means gnutls is not providing the server what it needs, so > it just waits until it hits the timeout, but I don't know how to proceed > to find out what is going wrong.
smptmail.el waits for the server greeting, which doesn't happen since the server waits for you to initiate the TLS connection first (which you can do using stunnel). It shouldn't be too difficult to adapt smtpmail.el to deal with this, but AFAIK ssmtp simply isn't standardized and every good mail provider should support SMTP+STARTTLS on the standard port.
>>> If the above swaks command works, you can use an external tool like >>> stunnel to set up the SSL connection. If you have root on the machine, >>> you can use stunnel like this
>>> You should then be able to send mails through your localhost on port >>> 2000. Note that the '-f' option lets stunnel run in the foreground for >>> testing purposes. If it works, you can omit this option and let stunnel >>> run as daemon.
>> I don't have root access to the machine that hosts the mail server, or >> do you mean the machine I use to send mail via the server?
> The latter.
>> If the latter, how would I make Gnus aware of the tunnel?
> Just point smptmail.el to your localhost on port 2000 (or whatever > you're writing in the above stunnel command).
Ok, I set smtpmail-default-smtp-server to "localhost" and smtpmail-auth-credentials to '(("localhost" 2000 "myusername" "mypassword")), and indeed it did work -- almost. Since the mail goes through localhost, it gets picked up by the postfix server running on my system. I have postfix configured to relay mail from localhost to another server (mail.gmx.net), which is what I use for most of my email. Unfortunately, mail.gmx.net does not accept relayed mail that has a non-GMX MAIL FROM (in this case myprovider.com) and bounces the mail. I don't know whether it is possible, and if so how, to configure postfix to handle mail intended to go through stunnel without relaying it to mail.gmx.net. Is it possible to use stunnel without going through localhost (but still sending the mail from this computer)?
>> I instrumented smtpmail.el for Edebug and stepped through the code as I >> tried to send a mail. The "freeze" occurred in smtpmail-read-response >> at the call to accept-process-output, which is from the Emacs C code. I >> assume this means gnutls is not providing the server what it needs, so >> it just waits until it hits the timeout, but I don't know how to proceed >> to find out what is going wrong.
> smptmail.el waits for the server greeting, which doesn't happen since > the server waits for you to initiate the TLS connection first (which you > can do using stunnel). It shouldn't be too difficult to adapt > smtpmail.el to deal with this, but AFAIK ssmtp simply isn't standardized > and every good mail provider should support SMTP+STARTTLS on the > standard port.
Unfortunately I don't know what adaptations to smtpmail.el would be needed nor how to implement them. If you want to try to do it, I would be grateful (as I am for the help you've already given me).
Stephen Berman <Stephen.Ber...@gmx.net> writes: > Ok, I set smtpmail-default-smtp-server to "localhost" and > smtpmail-auth-credentials to '(("localhost" 2000 "myusername" > "mypassword")), and indeed it did work -- almost. Since the mail goes > through localhost, it gets picked up by the postfix server running on my > system.
You local postfix listens on another port (25), so it should not pick up the mail. You must have done something wrong in your smtpmail.el configuration. Here's how it should work:
Note that smtp-server and smtp-service are set before the 'require' (though I'm not sure if this is still necessary).
> I have postfix configured to relay mail from localhost to > another server (mail.gmx.net), which is what I use for most of my > email.
I guess you could configure postfix to use different smart hosts dependent on the sender address, but I don't know postfix and it's OT here anyway.
> Unfortunately I don't know what adaptations to smtpmail.el would be > needed nor how to implement them. If you want to try to do it, I would > be grateful (as I am for the help you've already given me).
Sorry, I'm afraid I won't have the time to do it. Additionally, I consider ssmtp to be broken and mail servers usually only support it because of MS Outlook anyway, so I see no reason to support this. SMTP+STARTTLS is the right thing to do.
David <de...@arcor.de> writes: > Stephen Berman <Stephen.Ber...@gmx.net> writes: >> Ok, I set smtpmail-default-smtp-server to "localhost" and >> smtpmail-auth-credentials to '(("localhost" 2000 "myusername" >> "mypassword")), and indeed it did work -- almost. Since the mail goes >> through localhost, it gets picked up by the postfix server running on my >> system.
> You local postfix listens on another port (25), so it should not pick up > the mail. You must have done something wrong in your smtpmail.el > configuration. Here's how it should work:
> Note that smtp-server and smtp-service are set before the 'require' > (though I'm not sure if this is still necessary).
>> I have postfix configured to relay mail from localhost to >> another server (mail.gmx.net), which is what I use for most of my >> email.
> I guess you could configure postfix to use different smart hosts > dependent on the sender address, but I don't know postfix and it's > OT here anyway.
>> Stephen Berman <Stephen.Ber...@gmx.net> writes: >>> Ok, I set smtpmail-default-smtp-server to "localhost" and >>> smtpmail-auth-credentials to '(("localhost" 2000 "myusername" >>> "mypassword")), and indeed it did work -- almost. Since the mail goes >>> through localhost, it gets picked up by the postfix server running on my >>> system. [...] >> I guess you could configure postfix to use different smart hosts >> dependent on the sender address, but I don't know postfix and it's >> OT here anyway.
Thanks for posting this. It turns out I don't need it but it did help me resolve my problem (I deliberately don't say "solve" for reasons given below, and because my case is almost certainly different than the OP's).
Before trying your Elisp wrapper I tested msmtp with the --serverinfo and --port=465 flags and, frustratingly, it returned this:
msmtp: cannot get initial OK message from server msmtp: server message: 454 TLS connection failed: timed out (#4.3.0)
Since your use with Gmail works and it is also documented in the msmtp man page, I entered `msmtp --serverinfo --host=smtp.gmail.com --tls=on --port=587 --tls-certcheck=off' just to see what the output looks like, and after getting the Gmail server information, on a whim I replaced smtp.gmail.com with the FDQN of my mail server, leaving the other flags as they were -- and to my pleasant surprise, it succeeded and returned the server information. In other words, it worked with port 587 but not with port 465. Then I went back to my smtpmail.el settings, replaced 465 with 587, and it worked.
I do not understand why, as I reported earlier in this thread, both KMail and swaks use port 465. Moreover, when I tried port 587 with swaks it returned this:
In contrast EHLO with telnet to port 587 elicits the server's properties.
In short, KMail and swaks apparently need to access port 465 on this server, while telnet, msmtp, and smtpmail.el (or Gnutls) need to access port 587. If Richard or David or anyone else can account for this difference, I'd be interested to see it, but in any case, I'm happy I can finally access this server from within Emacs. And thanks again for the helpful feedback.