Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* sending mail: starttls and gnutls-cli sessions
@ 2009-04-27 10:27 Marco Maggi
  2009-04-30 19:07 ` Ted Zlatanov
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Maggi @ 2009-04-27 10:27 UTC (permalink / raw)
  To: info-gnus-english

Ciao,

  I want to send email through two remote servers, Gmail and
Poste.it, using  gnutls-cli for  authentication.  I am  on a
GNU+Linux system running Emacs 22.3.1 from the latest stable
Slackware package.

  I can successfully send mail through Gmail both using Gnus
and  using an  interactive  eshell session  in  which I  run
gnutls-cli directly and write  SMTP commands by hand.  Fine,
I know that it can work.

  When running the  eshell session for Gmail, I  do this: in
the eshell buffer

$ gnutls-cli --crlf --starttls --port 587 smtp.gmail.com

and the server replies with  a line of greetings; so I start
an SMTP dialogue and issue the STARTTLS SMTP command; now on
a xterm  I send a  SIGALRM signal to the  running gnutls-cli
process,  and  it establishes  the  encrypted bridge.   Then
everything  works.  I  assume that  this is  what  Gnus does
using the underlying libraries.

  Now with Poste.it I can  do the same on an eshell session,
but I have to leave out the "--starttls" option:

$ gnutls-cli --crlf --port 465 relay.poste.it

because  the  server  wants  the  encrypted  bridge  set  up
immediately.   Alternatively  I  can start  gnutls-cli  with
"--starttls" and immediately send  a SIGALRM to the process,
without waiting for server's greetings.

  Reading the  documentation of  Gnus and Smtpmail  I cannot
find a way to  select command line parameters for gnutls-cli
or to  tell it to  send SIGALRM immediately  without messing
with undocumented internal state of the libraries.

  I  see in  "starttls.el" that  a relevant  function  is be
`starttls-open-stream-gnutls'.  In the form:

(apply #'start-process name buffer
       starttls-gnutls-program "-s" host
       "-p" (if (integerp port) (int-to-string port) port)
       starttls-extra-arguments)

it  makes  use  of  the  "-s" option,  which  is  short  for
"--starttls".   So  the  way   to  go  is  to  send  SIGALRM
immediately.  Then the form:

    (while (and (processp process)
		(eq (process-status process) 'run)
		(save-excursion
		  (set-buffer buffer)
		  (goto-char old-max)
		  (not (setq done (re-search-forward
				   starttls-connect nil t)))))
      (accept-process-output process 0 100)
      (sit-for 0.1))

waits for  gnutls-cli text  telling that the  connection was
established ("Simple  Client Mode"); fine this  is should be
read correctly because I see it in the interactive session.

  So I have to turn  to "smtpmail.el", which is BIG!  Here I
guess  that  the problem  is  in `smtpmail-via-smtp',  which
seems  to   always  try  to  send  a   EHLO  command  before
considering a call to `starttls-negotiate'.

  My problem is that when `smtpmail-via-smtp' does:

(setq greeting (smtpmail-read-response process))

Gnus blocks waiting for  input that will never arrive, until
I stop it with C-g.

  What  to  do? Do  I  have to  send  a  feature request  to
someone?
-- Marco Maggi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sending mail: starttls and gnutls-cli sessions
  2009-04-27 10:27 sending mail: starttls and gnutls-cli sessions Marco Maggi
@ 2009-04-30 19:07 ` Ted Zlatanov
  2009-05-01  5:39   ` Marco Maggi
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Zlatanov @ 2009-04-30 19:07 UTC (permalink / raw)
  To: info-gnus-english

On Mon, 27 Apr 2009 12:27:06 +0200 Marco Maggi <marco.maggi-ipsu@poste.it> wrote: 

MM>   Now with Poste.it I can  do the same on an eshell session,
MM> but I have to leave out the "--starttls" option:

MM> $ gnutls-cli --crlf --port 465 relay.poste.it

MM> because  the  server  wants  the  encrypted  bridge  set  up
MM> immediately.   Alternatively  I  can start  gnutls-cli  with
MM> "--starttls" and immediately send  a SIGALRM to the process,
MM> without waiting for server's greetings.
...
MM>   My problem is that when `smtpmail-via-smtp' does:

MM> (setq greeting (smtpmail-read-response process))

MM> Gnus blocks waiting for  input that will never arrive, until
MM> I stop it with C-g.

MM>   What  to  do? Do  I  have to  send  a  feature request  to
MM> someone?

Can you write a shell script that will DTRT and open the connection?  If
yes, use that script to set up the tunnel and don't get Gnus involved
before the tunnel is running.

Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sending mail: starttls and gnutls-cli sessions
  2009-04-30 19:07 ` Ted Zlatanov
@ 2009-05-01  5:39   ` Marco Maggi
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Maggi @ 2009-05-01  5:39 UTC (permalink / raw)
  To: info-gnus-english


"Ted Zlatanov" wrote:
> Can you write  a shell script that will  DTRT and open the
> connection?  If yes, use that  script to set up the tunnel
> and don't get Gnus involved before the tunnel is running.

I have a  shell script that can send  an email message using
an  encrypted session;  I will  try  to use  it through  the
`message-send-mail-function' interface.

In  the meantime  I filed  a  feature request  on the  Emacs
mailing list.
-- 
Marco Maggi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-01  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-27 10:27 sending mail: starttls and gnutls-cli sessions Marco Maggi
2009-04-30 19:07 ` Ted Zlatanov
2009-05-01  5:39   ` Marco Maggi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).