Sending email using emacs24 via smtp using gnutls and optional arguments

I have a rather strange problem using sending emails from emacs24 with my email posteo account, but everything seems to work fine with gmail and gmx. This is the actual part of my current .emacs configuration (it seems that I redid it a million times with the same results):

(require 'smtpmail)
(require 'starttls)

(setq message-send-mail-function 'smtpmail-send-it)
(setq tls-program '("gnutls-cli --priority NORMAL:%COMPAT -p %p %h"))
(setq starttls-gnutls-program "gnutls-cli --priority NORMAL:%COMPAT")
(setq starttls-use-gnutls t)
(setq smtpmail-stream-type 'starttls)
(setq smtpmail-smtp-server "posteo.de")
(setq smtpmail-debug-info t)
(setq smtpmail-debug-verb t)
(setq smtpmail-smtp-service 587) ;;587(starttls) or 465(tls/ssl) or ?
(setq starttls-extra-arguments '("--priority NORMAL:%COMPAT"))

The output in my message buffer is:

Sending via mail...
235 2.7.0 Authentication successful
gnutls.c: [0] (Emacs) fatal error: A TLS fatal alert has been received.
gnutls.c: [0] (Emacs) Received alert:  Bad record MAC
smtpmail-send-command: Process smtpmail not running

and in my SMTP trace to posteo.de buffer:

220 mail.posteo.de ESMTP Postfix
250-mail.posteo.de
250-PIPELINING
250-SIZE 76800000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
220 2.0.0 Ready to start TLS
250-mail.posteo.de
250-PIPELINING
250-SIZE 76800000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH PLAIN <omitted>
235 2.7.0 Authentication successful

Process smtpmail connection broken by remote peer
MAIL FROM:<c.bourjau@posteo.de> SIZE=281
QUIT

The problem seems to be a certificate that seems to have the wrong "paddings" (I'm not quite sure what it is) http://gnutls.org/manual/html_node/On-Record-Padding.html , Another way to create a similar error on the command line with this server is to do:

$ gnutls-cli --starttls -p 587 posteo.de
Resolving 'posteo.de'...
Connecting to '89.146.220.134:587'...

- Simple Client Mode:

220 mail.posteo.de ESMTP Postfix
*** Starting TLS handshake
*** Fatal error: An unexpected TLS packet was received.
*** Handshake has failed

, --priority NORMAL:%COMPAT gnutls, (..emacs).

, : emacs?

!

+4
1

: gnutls emacs 24

emacs24, , starttls-gnutls-program, gnutls-available-p nil, , .

:

(require 'smtpmail)
(require 'starttls)

(setq message-send-mail-function 'smtpmail-send-it)
(defun gnutls-available-p ()
  "Function redefined in order not to use built-in GnuTLS support"
  nil)
(setq starttls-gnutls-program "gnutls-cli")
(setq starttls-use-gnutls t)
(setq smtpmail-stream-type 'starttls)
(setq smtpmail-smtp-server "posteo.de")
(setq smtpmail-smtp-service 587) ;;587(starttls) or 465(tls/ssl)
(setq starttls-extra-arguments '("--priority" "NORMAL:%COMPAT"))
+5

Source: https://habr.com/ru/post/1534934/


All Articles