[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Dynamically switching send-mail settings (WAS: > 24.3 can't send mail)
From: |
Tory S. Anderson |
Subject: |
Dynamically switching send-mail settings (WAS: > 24.3 can't send mail) |
Date: |
Sat, 07 Feb 2015 22:51:45 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
I'm very near to regaining my 24.3 Gnus send mail functionality of being able
to dynamically send from any of my multiple addresses and having the server
information change accordingly. Using the function below it does indeed change
the server info at send-time, and there is a matching entry in .authinfo. But I
receive the (mostly successful) output:
Sending via mail...
Failed to match ...
Failed to match ...
Failed to match ...
Failed to match ...
Setting SMTP server to `smtp.gmail2.com:587' for user <CORRECT-MATCH>
Opening TLS connection to `smtp.gmail2.com'...
Opening TLS connection with `gnutls-cli --insecure -p 587
smtp.gmail2.com'...failed
Opening TLS connection with `gnutls-cli --insecure -p 587 smtp.gmail2.com
--protocols ssl3'...failed
Opening TLS connection with `openssl s_client -connect smtp.gmail2.com:587
-no_ssl2 -ign_eof'...done
And, at that, it freezes with the final line in my message buffer until I C-g
to safety. Any ideas why it freezes at this point, having done the dynamic
setting correctly? Note that I've successfully sent with this account today
before I started working on the dynamic switching, so I know the settings are
otherwise correct. Below are the functions I'm using:
--8<---------------cut here---------------start------------->8---
(defvar smtp-accounts
'(
("me@mine.com" "mail.mine.com" 26);; Personal
("mail@me.com" "mail.mine3.com" 26);; Professional
("me2@mine.com" "mail.mine2.com" 26) ;; Web development
("mine@gmail.com" "smtp.gmail.com" 587) ;; Public
))
(defun set-smtp (server port user)
"Set related SMTP variables for supplied parameters. String `user'
will not be evaluated."
(setq smtpmail-smtp-server server smtpmail-smtp-service port)
(message "Setting SMTP server to `%s:%s' for user `%s'."
server port user))
(defun change-smtp ()
"Change the SMTP server according to the current from line."
(save-excursion
(cl-loop with from = (save-restriction
(message-narrow-to-headers)
(message-fetch-field "from"))
for (address server port) in smtp-accounts
do (if (string-match address from)
(return (funcall 'set-smtp server port address))
(message "Failed to match %s with %s" address from))
finally (error "Cannot infer SMTP information."))))
(add-hook 'message-send-mail-hook 'change-smtp)
--8<---------------cut here---------------end--------------->8---
- > 24.3 can't send mail, Tory S. Anderson, 2015/02/07
- Re: > 24.3 can't send mail, Tory S. Anderson, 2015/02/07
- Re: > 24.3 can't send mail, Eli Zaretskii, 2015/02/07
- Re: > 24.3 can't send mail, Tory S. Anderson, 2015/02/07
- Re: > 24.3 can't send mail, Sivaram Neelakantan, 2015/02/07
- Dynamically switching send-mail settings (WAS: > 24.3 can't send mail),
Tory S. Anderson <=
- Re: Dynamically switching send-mail settings (WAS: > 24.3 can't send mail), Robert Thorpe, 2015/02/08
- Re: Dynamically switching send-mail settings, Tory S. Anderson, 2015/02/08
- Message not available
- Re: Dynamically switching send-mail settings, Lars Magne Ingebrigtsen, 2015/02/09
- Re: Dynamically switching send-mail settings, Tory S. Anderson, 2015/02/09
- Re: Dynamically switching send-mail settings, Lars Ingebrigtsen, 2015/02/17
- Re: Dynamically switching send-mail settings, Tory S. Anderson, 2015/02/17