本文介绍了通过带有gnutls和额外参数的smtp发送带有emacs24的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用posteo电子邮件帐户从emacs24发送电子邮件时,我遇到了一个很奇怪的问题,但对于gmail和gmx来说,一切似乎都可以正常工作。这是我当前.emacs配置的相关部分(感觉我将它排列了一百万次,结果始终相同):

I have a rather weird problem with using sending out emails from emacs24 with my posteo email account, but everything seems to work just fine with gmail and gmx. This is the relevant part of my current .emacs configuration (it feels like I permuted it a million times with always 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"))

我的 message 缓冲区中的输出是:

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

以及我的 SMTP跟踪中的posteo.de 缓冲区:

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:<[email protected]> SIZE=281
QUIT

问题似乎出在证书上,似乎出现了错误的填充。 (我不太确定这是什么)。使用此服务器在命令行上产生类似错误的另一种方法是:

The problem seems to be a certificate which appears to have wrong "paddings" (I am not really sure what this is) http://gnutls.org/manual/html_node/On-Record-Padding.html. Another way to produce 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)。

This error is supposedly fixed if one adds the --priority NORMAL:%COMPAT to the gnutls argument which I tried to no avail (see .emacs).

所以问题是:如何治疗证明在emacs中引发了此类错误?

So the question is: How does on treat certifcates throwing these kind of errors in emacs?

非常感谢!

推荐答案

这篇文章给了我关键的提示:

This post gave me the crucial hint: How to ask gnutls to use client certificate in emacs 24

emacs24似乎忽略了 starttls-gnutls-program gnutls-available-p 不是 nil ,则c>变量,必须通过重写后者的函数来强制执行。

emacs24 seems to ignore the starttls-gnutls-program variable if gnutls-available-p is not nil, which has to be force by overwriting the latter function.

我的工作配置如下:

(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"))

这篇关于通过带有gnutls和额外参数的smtp发送带有emacs24的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 15:21