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"))
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 trace of SMTP 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 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
This error is supposedly fixed if one adds the --priority NORMAL:%COMPAT to the gnutls argument which I tried to no avail (see .emacs).
So the question is: How does on treat certifcates throwing these kind of errors in emacs?
Thanks a lot in advance!
This post gave me the crucial hint: How to ask gnutls to use client certificate in emacs 24
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.
My working configuration is now the following:
(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"))
Related
I referenced the answer to question sending-emails-with-emacs24-via-smtp-with-gnutls-and-extra-arguments
and set my config as
(setq user-mail-address "abst.proc.do#qq.com")
(setq user-full-name "abst.proc.do")
(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 "smtp.qq.com")
(setq smtpmail-smtp-service 587) ;;587(starttls) or 465(tls/ssl)
(setq starttls-extra-arguments '("--priority" "NORMAL:%COMPAT"))
Then try to send a testing mail as
From: abst.proc.do#qq.com (abst.proc.do)
To: abst.proc.do#qq.com
Subject: Testing
Date: Thu, 23 Jan 2020 07:11:44 +0800
Message-ID: <877e1j2ij3.fsf#qq.com>
--text follows this line--
Testing
It freeze in the minibuffer with prompt
Opening STARTTLS connection to ‘smtp.qq.com:587’...done
and got a messages
Saving file /home/me/*message*-20200123-071130...
the mail was not sent.
The appreciate stmp service was checked and token placed in .authinfo
What's the problem with my configuration?
Machine: Ubuntu 19.10 Emacs 26.3
The error trace:
220 newxmesmtplogicsvrszc2.qq.com XMail Esmtp QQ Mail Server.
250-newxmesmtplogicsvrszc2.qq.com
250-PIPELINING
250-SIZE 73400320
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN
250-MAILCOMPRESS
250 8BITMIME
Process smtpmail deleted
220 newxmesmtplogicsvrsza3.qq.com XMail Esmtp QQ Mail Server.
250-newxmesmtplogicsvrsza3.qq.com
250-PIPELINING
250-SIZE 73400320
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN
250-MAILCOMPRESS
250 8BITMIME
220 Ready to start TLS from 106.39.174.180 to newxmesmtplogicsvrsza3.qq.com.
*** Starting TLS handshake
- Certificate type: X.509
- Got a certificate list of 3 certificates.
- Certificate[0] info:
- subject `CN=*.mail.qq.com,O=Tencent Technology (Shenzhen) Company Limited,L=shenzhen,ST=guangdong,C=CN', issuer `CN=GlobalSign Organization Validation CA - SHA256 - G2,O=GlobalSign nv-sa,C=BE', serial 0x41110235e23a37f3ead2dc5e, RSA key 2048 bits, signed using RSA-SHA256, activated `2019-11-11 10:32:16 UTC', expires `2020-06-03 04:00:33 UTC', pin-sha256="3gHtBaJCDCS2wo6ho7kKEE6rUA1YXM3A6R1XiFejm48="
Public Key ID:
sha1:5df67c6c87174f49828307072b0922d6da77cab0
sha256:de01ed05a2420c24b6c28ea1a3b90a104eab500d585ccdc0e91d578857a39b8f
Public Key PIN:
pin-sha256:3gHtBaJCDCS2wo6ho7kKEE6rUA1YXM3A6R1XiFejm48=
- Certificate[1] info:
- subject `CN=GlobalSign Organization Validation CA - SHA256 - G2,O=GlobalSign nv-sa,C=BE', issuer `CN=GlobalSign Root CA,OU=Root CA,O=GlobalSign nv-sa,C=BE', serial 0x040000000001444ef04247, RSA key 2048 bits, signed using RSA-SHA256, activated `2014-02-20 10:00:00 UTC', expires `2024-02-20 10:00:00 UTC', pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4="
- Certificate[2] info:
- subject `CN=GlobalSign Root CA,OU=Root CA,O=GlobalSign nv-sa,C=BE', issuer `CN=GlobalSign Root CA,OU=Root CA,O=GlobalSign nv-sa,C=BE', serial 0x040000000001154b5ac394, RSA key 2048 bits, signed using RSA-SHA1 (broken!), activated `1998-09-01 12:00:00 UTC', expires `2028-01-28 12:00:00 UTC', pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="
- Status: The certificate is trusted.
- Description: (TLS1.2)-(ECDHE-SECP256R1)-(RSA-SHA512)-(AES-128-GCM)
- Session ID: CB:34:DB:07:B8:3D:32:D8:13:BD:9B:4E:6B:5D:0A:72:1A:85:83:20:68:BB:70:8A:5A:43:15:51:3E:7D:19:BD
- Options: safe renegotiation,
I have had a number of ongoing problems with starttls, i.e. open-tls-stream, when it is using openssl in Emacs -- it is extremely hard to debug, and upgrading either emacs or openssl can cause connections to hang as you have observed -- and this usually happens far enough apart to allow one to completely forget that it happened before and how to debug and fix it again.
I've changed the definition of tls-end-of-info to solve this:
;; xxx gnutls-cli is broken, at least when used with emacs-23.3
;; (xxx "-no_ssl2" might still be required for older openssl?)
;; n.b. the "-crlf" is now necessary for Gmail, but not Cyrus
;;
(setq tls-program '("openssl s_client -connect %h:%p -ign_eof"))
(setq starttls-use-gnutls nil) ; XXX requires security/starttls be installed!!!
;;
;; XXX as of OpenSSL 1.1.1a 20 Nov 2018 there's a new ending to the noise
;; c_client prints before real data starts.
;;
;; (XXX debugging this was HARD! No clues -- emacs just "hung" without responding)
;;
(setq tls-end-of-info
"\\(^\s*Verify return code: .+
---
\\|^ Extended master secret: .+
---
\\|^- Simple Client Mode:
\\(
\\|^\\*\\*\\* Starting TLS handshake
\\)*\\)")
To help with the debugging I use a slightly hacked up version of open-tls-stream. You can find it all at my ~/.emacs.el file
I’m having trouble with cl-smtp:send-email which seems to stem from a timeout error when calling usocket:socket-connect.
Here is what I am trying to do:
(cl-smtp:send-email "outgoing.mit.edu" "m_klein#mit.edu"
(list "m_klein#mit.edu") "s1" "m1”)
This seems to be the call where the failure occurs (according to the backtrace):
(usocket:socket-connect "outgoing.mit.edu" 25
:protocol :stream
:element-type '(unsigned-byte 8)
:timeout nil
:deadline nil
:nodelay nil
:local-host nil
:local-port nil)
Here is the error:
Error: Error #<USOCKET:TIMEOUT-ERROR #x302001E5FDED>
While executing: USOCKET::RAISE-ERROR-FROM-ID, in process Listener(475).
The odd thing is that the same function call has worked on other machines, but not on my current mac laptop or the cloud-based mac I’ve also been using.
I am running Clozure Common Lisp 1.11.1 on a MacBook Pro on OS 10.13.3
Here are snapshots of the backtrace FYI: https://imgur.com/a/e2xcf
Any ideas? Any help would be greatly appreciated.
Since you are using an external server, first you need to check, correctness of the address (connect using telnet), port and maybe you need an authentication.
Since you are using cl-smtp, first I recommend you to test how it works, for that the easy way of testing smptp is using mailcatcher inside a docker container:
docker run -d -p 1080:1080 -p 1025:1025 --name mailcatcher schickling/mailcatcher
docker ps | grep mailcatcher
6fb056fceb6b schickling/mailcatcher "mailcatcher -f --ip…" 9 months ago Up 18 minutes 0.0.0.0:1025->1025/tcp, 0.0.0.0:1080->1080/tcp mailcatcher
Then you can access to the ourtgoing mail in a web browser localhost:1080, and send mail to localhost:1025
For testing the SMTP, server I recommend to use telnet:
telnet
telnet> o localhost 1025
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 EventMachine SMTP Server
EHLO localhost
250-Ok EventMachine SMTP Server
250-NO-SOLICITING
250 SIZE 20000000
there is a great article on that here
When you are sure that, you get the requirements try with lisp:
CL-USER> (cl-smtp:send-email "127.0.0.1" "antonio.querol#example.com" "pedro.lopez#example.com" "Say Hello" "Hello World"
:port 1025)
("Ok")
I am trying to configure gnus to work with my gmail account. My .gnus file looks like this:
(setq gnus-select-method '(nntp "news.gwene.org"))
(setq user-full-name "George P. Burdell")
(setq user-mail-address "probablyReal#gmail.com")
(setq smtpmail-auth-credentials "~/.authinfo.epg")
(add-to-list 'gnus-secondary-select-methods
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)
(nnimap-authinfo-file "~/.authinfo.epg")
)
)
(setq smtpmail-stream-type 'ssl
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 465)
and my .authinfo.epg file looks like this:
machine imap.gmail.com login probablyReal#gmail.com password secret port 993
machine smtp.gmail.com login probablyReal#gmail.com password secret port 465
and the error that it throws is:
Generating the cache active file...done
Opening nnfolder server on archive...done
Opening nnimap server on gmail...
Opening connection to imap.gmail.com via tls...
Opening TLS connection to `imap.gmail.com'...
Opening TLS connection with `gnutls-cli --insecure -p 993 imap.gmail.com'...failed
Opening TLS connection with `gnutls-cli --insecure -p 993 imap.gmail.com --protocols ssl3'...failed
Opening TLS connection with `openssl s_client -connect imap.gmail.com:993 -no_ssl2 -ign_eof'...failed
Opening TLS connection to `imap.gmail.com'...failed
Unable to open server nnimap+gmail due to: Buffer *nnimap imap.gmail.com 993 *nntpd** has no process
Opening nnimap server on gmail...failed:
No new newsgroups
Checking new news...
Reading active file from gmail via nnimap...
Opening nnimap server on gmail...
Server nnimap+gmail previously determined to be down; not retrying
Opening nnimap server on gmail...failed:
Reading active file via nndraft...done
Checking new news...done
Warning: Opening nnimap server on gmail...failed: ; Server nnimap+gmail previously determined to be down; not retrying; Opening nnimap server on gmail...failed: ; Unable to open server nnimap+gmail due to: Buffer *nnimap imap.gmail.com 993 *nntpd** has no process
(sorry for wall of text)
finally, when I evaluate this:
(gnutls-available-p)
it simply prints:
nil
I'm running emacs for windows 8, I'm not using cygwin, and I really can't figure out what the problem is, even after seraching for hours.
edit: I've tried both of these (as well as combinations from both) and get the same errors:
http://blog.binchen.org/posts/notes-on-using-gnus.html
http://www.emacswiki.org/emacs/GnusGmail
My guess would be that Emacs on Windows doesn't come with the required libraries, hence (gnutls-available-p) returns nil for you. You'll have to install gnutls somewhere so that your Emacs will be able to find it, cf. the GnuTLS homepage. You probably have to put the downloaded Windows library into the directory where Emacs is looking for it's libraries.
I write emails in emacs via mu4e. If I specify starttls instead of ssl in the following code, smtpmail can send the messages:
;; sending mail (see Appendix B.3.2 of the mu4e manual)
(setq send-mail-function 'smtpmail-send-it
messsage-send-mail-function 'smtpmail-send-it; use smtpmail for sending mails
smtpmail-stream-type 'ssl; starttls works here, why not ssl?
smtpmail-default-smtp-server "mail.uni.edu"; default smtp server
smtpmail-smtp-server "mail.uni.edu"; host name of the SMTP server
smtpmail-smtp-service "smtp"); controls the port on the server to contact
However, for ssl, I obtain (output of *Messages*):
Sending via mail...
gnutls.c: [0] (Emacs) fatal error: An unexpected TLS packet was received.
gnutls.el: (err=[-15] An unexpected TLS packet was received.) boot: (:priority NORMAL :hostname mail.ethz.ch :loglevel 0 :min-prime-bits 256 :trustfiles (/etc/ssl/certs/ca-certificates.crt) :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :verify-hostname-error nil :callbacks nil)
gnutls-negotiate: GnuTLS error: #<process smtpmail>, -15
gnutls.c: [0] (Emacs) fatal error: An unexpected TLS packet was received. [100 times]
What's wrong?
Replace "smtp" by 465 and it works.
I am getting SMTP Authentication Failure on the server and the mail is getting send via the server SMTP only...
It appears to be a server configuration or related problem, but I am not sure.
This is the debug details:
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
Failed to authenticate password. Error: 535 Incorrect authentication data
from: 250 OK
to: 250 Accepted
data: 354 Enter message, ending with "." on a line by itself
250 OK id=1U8Pjp-0002As-FB
quit: 221 ************** closing connection
Your message has been successfully sent using the following protocol: smtp
While testing from my local system, this works and the email is being sent via sendgrid.me
Again, This may not be a SendGrid Problem, but if you have faced similar issue, Can you please tell me what is the problem here?
I am using CentOs and I have cPanel in the server. I believe we are using EXIM for mail server.
For anyone that comes across this in future and are using cpanel/whm, you need to 'disable' this option under 'SMTP Restrictions' in WHM.
I was able to resolve this.
The issue was my server was not allowing the use of external SMTP and using its own SMTP server. I changed the settings and now it works fine.
I am using centos 7 Finally it works!
I was getting this issue(tail -f /var/log/mailog):
to=<usmanali#example.com>, relay=smtp.sendgrid.net[169.45.113.201]:587, delay=0.3, delays=0.05/0.07/0.16/0.02, dsn=5.0.0, status=bounced (host smtp.sendgrid.net[169.45.113.201] said: 550 Unauthenticated senders not allowed (in reply to MAIL FROM command))
Then i changed file /etc/postfix/main.cf in this way that added following lines into end of file
mtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
mailbox_size_limit = 256000000
# Sendgrid Settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:SG.YOUR_SENDGRID_KEY
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
Then Installing postfix missing module dependency using:
sudo yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
Then restarting postfix
sudo systemctl restart postfix.service