aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/doom/config.org36
1 files changed, 21 insertions, 15 deletions
diff --git a/config/doom/config.org b/config/doom/config.org
index 566a3ac..75ebc18 100644
--- a/config/doom/config.org
+++ b/config/doom/config.org
@@ -413,21 +413,27 @@ this new window.
smtpmail-local-domain "oscarnajera.com")
(defun set-smtp-server ()
- (let* ((default-smtp-conf '("mail.oscarnajera.com" 587 starttls "hi"))
- (smtp-from-server-alist
- '(("Oscar Najera <najera.oscar@gmail.com>"
- "smtp.googlemail.com" 587 starttls "najera.oscar")))
- (smtp-conf (alist-get (save-restriction
- (message-narrow-to-headers)
- (message-fetch-field "from"))
- smtp-from-server-alist default-smtp-conf
- nil #'string=)))
- (-let [(server port protocol user) smtp-conf]
- (setq smtpmail-smtp-server server
- smtpmail-smtp-service port
- smtpmail-stream-type protocol
- smtpmail-smtp-user user)
- (message "SMTP server changed to %s in port %s by %s" server port protocol))))
+ (-let* (((user host)
+ (thread-first
+ (message-field-value "from" )
+ (mail-extract-address-components)
+ (cadr)
+ (string-split "@")))
+ (smtp-servers '("oscarnajera.com" "mail.oscarnajera.com"
+ "gmail.com" "smtp.googlemail.com"
+ "byteplant.com" "smtp.byteplant.com"))
+ ((&plist :host :user :port :secret)
+ (car
+ (auth-source-search :host
+ (or (plist-get smtp-servers host #'string=)
+ "mail.oscarnajera.com")
+ :user user
+ :max 1))))
+ (setq smtpmail-smtp-server host
+ smtpmail-smtp-service (string-to-number port)
+ smtpmail-stream-type 'starttls
+ smtpmail-smtp-user user)
+ (message "SMTP server changed to %s %s %s" host port user)))
(add-hook 'message-send-mail-hook 'set-smtp-server))
#+end_src