aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2012-02-09 23:42:12 +0100
committerLars Ingebrigtsen2012-02-09 23:42:12 +0100
commit4c7e65bf4f3fb9d24ec23f68047486c3c182ff65 (patch)
treeb84674d1a59e99e203e6c8747b9b63ff2a60614f
parentf3934f6fef7316982750c311b27961bd31109baa (diff)
downloademacs-4c7e65bf4f3fb9d24ec23f68047486c3c182ff65.tar.gz
emacs-4c7e65bf4f3fb9d24ec23f68047486c3c182ff65.zip
Get the MAIL FROM from the From: header if no domain is configured
* mail/smtpmail.el (smtpmail-user-mail-address): New function. (smtpmail-via-smtp): Use it, or fall back on the From address. (smtpmail-send-it): Ditto.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/mail/smtpmail.el28
2 files changed, 29 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a0de2c88ac4..0769badf4f5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12012-02-09 Lars Ingebrigtsen <larsi@rusty>
2
3 * mail/smtpmail.el (smtpmail-user-mail-address): New function.
4 (smtpmail-via-smtp): Use it, or fall back on the From address.
5 (smtpmail-send-it): Ditto.
6
12012-02-09 Stefan Monnier <monnier@iro.umontreal.ca> 72012-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * emacs-lisp/bytecomp.el (byte-compile-file-form-defvar): 9 * emacs-lisp/bytecomp.el (byte-compile-file-form-defvar):
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index e3051fd0c9f..99283bebf9d 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -200,7 +200,10 @@ The list is in preference order.")
200 ;; local binding in the mail buffer will take effect. 200 ;; local binding in the mail buffer will take effect.
201 (smtpmail-mail-address 201 (smtpmail-mail-address
202 (or (and mail-specify-envelope-from (mail-envelope-from)) 202 (or (and mail-specify-envelope-from (mail-envelope-from))
203 user-mail-address)) 203 (smtpmail-user-mail-address)
204 (let ((from (mail-fetch-field "from")))
205 (and from
206 (cadr (mail-extract-address-components from))))))
204 (smtpmail-code-conv-from 207 (smtpmail-code-conv-from
205 (if enable-multibyte-characters 208 (if enable-multibyte-characters
206 (let ((sendmail-coding-system smtpmail-code-conv-from)) 209 (let ((sendmail-coding-system smtpmail-code-conv-from))
@@ -611,6 +614,15 @@ The list is in preference order.")
611 (unless smtpmail-smtp-server 614 (unless smtpmail-smtp-server
612 (error "Couldn't contact an SMTP server")))) 615 (error "Couldn't contact an SMTP server"))))
613 616
617(defun smtpmail-user-mail-address ()
618 "Return `user-mail-address' if it's a valid email address."
619 (and user-mail-address
620 (let ((parts (split-string user-mail-address "@")))
621 (and (= (length parts) 2)
622 ;; There's a dot in the domain name.
623 (string-match "\\." (cadr parts))
624 user-mail-address))))
625
614(defun smtpmail-via-smtp (recipient smtpmail-text-buffer 626(defun smtpmail-via-smtp (recipient smtpmail-text-buffer
615 &optional ask-for-password) 627 &optional ask-for-password)
616 (unless smtpmail-smtp-server 628 (unless smtpmail-smtp-server
@@ -621,10 +633,16 @@ The list is in preference order.")
621 (port smtpmail-smtp-service) 633 (port smtpmail-smtp-service)
622 ;; `smtpmail-mail-address' should be set to the appropriate 634 ;; `smtpmail-mail-address' should be set to the appropriate
623 ;; buffer-local value by the caller, but in case not: 635 ;; buffer-local value by the caller, but in case not:
624 (envelope-from (or smtpmail-mail-address 636 (envelope-from
625 (and mail-specify-envelope-from 637 (or smtpmail-mail-address
626 (mail-envelope-from)) 638 (and mail-specify-envelope-from
627 user-mail-address)) 639 (mail-envelope-from))
640 (smtpmail-user-mail-address)
641 ;; Fall back on the From: header as the envelope From
642 ;; address.
643 (let ((from (mail-fetch-field "from")))
644 (and from
645 (cadr (mail-extract-address-components from))))))
628 response-code 646 response-code
629 process-buffer 647 process-buffer
630 result 648 result