I'm trying to configure emacs to send mail through an SMTP server, but so far, I've not been successful. Here's the output I'm getting:
220 __SMTP.SERVER__ ESMTP Sendmail 8.14.4+UW11.03/8.14.4+UW13.09; Wed, 15 Jan 2014 13:16:39 -0800
250-__SMTP.SERVER__ Hello __LOCAL.DOMAIN__ [__IP.ADDRESS__], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE 60000000
250-DSN
250-AUTH GSSAPI
250-STARTTLS
250-DELIVERBY
250 HELP
250 2.0.0 Verbose mode
250 2.1.0 <__USER@DOMAIN__>... Sender ok
530 5.7.1 Relaying denied. Proper authentication required.
smtpmail-send-it: Sending failed; SMTP protocol error
Relevant init.el is setup thus:
(setq send-mail-function 'smtpmail-send-it)
(setq smtpmail-smtp-server "__SMTP.SERVER__")
(setq smtpmail-smtp-service 587)
(setq smtpmail-stream-type 'ssl)
(setq smtpmail-debug-info t)
(setq smtpmail-debug-verb t)
There also exists a .authinfo file, which reads:
machine __SMTP.SERVER__ port 587 login __USER__ password *
Any thoughts on what I've missed or done incorrectly?
EDIT 1
@techie007 I've talked with the server admin, and he's told me that the server is supposed to allow relaying after authentication; now I'm wondering if I've set up my authentication incorrectly. I know that the server uses TLS encryption, and I know that I've configured smtpmail-stream-type 'ssl
instead of 'tls
, but the emacs documentation led me to believe that 'ssl
is to be used for both SSL and TLS connections (http://www.gnu.org/software/emacs/manual/html_mono/smtpmail.html#Encryption). Is this wrong?
Additionally, the SMTP server does indeed work with other clients; it's just this particular connection that I'm having trouble making.
EDIT 2
A retooling of init.el now reads:
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-starttls-credentials '(("__SMPT.SERVER__" 587 nil nil))
smtpmail-auth-credentials '(("__SMTP.SERVER" 587 "__USER__" nil))
smtpmail-default-smtp-server "__SMTP_SERVER__"
smtpmail-smtp-server "__SMTP.SERVER__"
smtpmail-smtp-service 587
smtpmail-local-domain "__LOCAL.DOMAIN__")
which has removed the need for a .authinfo file. Full log including an attempt to send mail:
Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50psvn.el (source)...done
Loading /etc/emacs23/site-start.d/50vm-init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
goto-history-element: Beginning of history; no preceding item
Quit
Loading /home/__USER__/.xemacs/init.el (source)...done
Loading /home/__USER__/.xemacs/custom.el (source)...done
/usr/bin/mail is not an executable. Setting mail-interactive to t.
Adding vm-rfaddons-option `check-recipients'.
Adding vm-rfaddons-option `check-for-empty-subject'.
Adding vm-rfaddons-option `encode-headers'.
VM-RFADDONS: VM is now infected.
ispell.el is already loaded
Sending...
Added to /home/__USER__/vm-folders/SentMail
sendmail-send-it: Sending...failed with exit value 1
EDIT 3
I've managed to make some progress! On initial startup of Emacs, I start VM with C-x m
, and if I try to send a message, I'm met with the failure in the first output - smtpmail-send-it: Sending failed; SMTP protocol error
. However, if I C-x C-f ~/.emacs
to open the file and then enter M-x eval-buffer
, I can then go back into VM and send a message perfectly fine. The .emacs configuration is thus:
(setq message-send-mail-function 'smtpmail-send-it
send-mail-function 'smtpmail-send-it
smtpmail-default-smtp-server "__SMTP.SERVER__"
smtpmail-smtp-server "__SMTP.SERVER__"
smtpmail-smtp-service 587
smtpmail-stream-type 'ssl
smtpmail-auth-credentials '(("__SMTP.SERVER__" 587 "__USER__" "__PASSWORD__"))
)
Does anybody know how I can eliminate the need to evaluate .emacs
at the start of every Emacs session?
FINAL EDIT
It works! For closure's sake, let me post my final working configuration here.
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/vm/")
(require 'vm-autoloads)
(load "/usr/local/share/emacs/site-lisp/vm/vm-reply")
(setq message-send-mail-function 'smtpmail-send-it
send-mail-function 'smtpmail-send-it
user-mail-address "__USER.MAIL.ADDRESS__"
smtpmail-default-smtp-server "__SMTP.SERVER__"
smtpmail-smtp-server "__SMTP.SERVER__"
smtpmail-smtp-service 587
smtpmail-stream-type 'ssl
smtpmail-smtp-user "__USER__"
smtpmail-starttls-credentials '(("__SMTP.SERVER__" 587 "__USER__" nil)))
starttls-use-gnutls t
starttls-gnutls-program "gnutls-cli"
starttls-extra-arguments nil
)
Putting in the 'load-path
and 'vm-autoloads
seemed to help with a couple of "function definition is void" errors, and the manual load of vm-reply
is a workaround to a bug found in VM 8.2.0b, consisting of a missing autoload; otherwise, it resulted in a void definition of vm-select-recipient-from-sender
. I also went back to using the .authinfo file to authenticate once I realized that it was conflicting with the smtpmail-auth-credentials
variable; smtpmail-smtp-user
is used in conjunction with .authinfo as per netawater's suggestion. user-mail-address
solved any remaining authentication errors I had.
Thanks, everyone, for all your help and suggestions!