Skip to content

Instantly share code, notes, and snippets.

@antifuchs
Created March 5, 2014 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antifuchs/9373768 to your computer and use it in GitHub Desktop.
Save antifuchs/9373768 to your computer and use it in GitHub Desktop.
;;; SMTP settings:
;; Available SMTP accounts.
(require 'smtpmail)
(setq smtpmail-smtp-server "smtp.gmail.com"
smtpmail-smtp-service 587
starttls-use-gnutls t
send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
mail-from-style 'angles
smtpmail-debug-info t
smtpmail-debug-verb t)
(defun asf-change-smtp ()
"Change gmail SMTP auth to what's in the from field."
(save-excursion
(save-restriction
(message-narrow-to-headers)
(let* ((from (message-fetch-field "from"))
(address (cadr (mail-extract-address-components from))))
(setq smtpmail-smtp-user address)))))
(add-hook 'message-send-hook 'asf-change-smtp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment