(smtpmail-via-smtp): Add support for
authorGerd Moellmann <gerd@gnu.org>
Thu, 14 Oct 1999 22:09:58 +0000 (22:09 +0000)
committerGerd Moellmann <gerd@gnu.org>
Thu, 14 Oct 1999 22:09:58 +0000 (22:09 +0000)
automatically appending a domain to RCPT TO: addresses.

lisp/ChangeLog
lisp/mail/smtpmail.el

index 01e3a4e..ae1777a 100644 (file)
@@ -1,3 +1,8 @@
+1999-10-15  Gerd Moellmann  <gerd@gnu.org>
+
+       * smtpmail.el (smtpmail-via-smtp): Add support for
+       automatically appending a domain to RCPT TO: addresses.
+
 1999-10-14  Richard M. Stallman  <rms@caffeine.ai.mit.edu>
 
        * dired.el (dired-insert-directory): Insert the amount of
index 9b1ce02..6f53489 100644 (file)
@@ -1,4 +1,6 @@
 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
+;;; ###        Hacked by Mike Taylor, 11th October 1999 to add support for
+;;;    automatically appending a domain to RCPT TO: addresses.
 
 ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
 
@@ -34,6 +36,7 @@
 ;;(setq message-send-mail-function 'smtpmail-send-it) ; if you use `message'
 ;;(setq smtpmail-default-smtp-server "YOUR SMTP HOST")
 ;;(setq smtpmail-local-domain "YOUR DOMAIN NAME")
+;;(setq smtpmail-sendto-domain "YOUR DOMAIN NAME")
 ;;(setq smtpmail-debug-info t) ; only to debug problems
 
 ;; To queue mail, set smtpmail-queue-mail to t and use 
@@ -74,6 +77,28 @@ don't define this value."
   :type '(choice (const nil) string)
   :group 'smtpmail)
 
+(defcustom smtpmail-sendto-domain nil
+  "*Local domain name without a host name.
+This is appended (with an @-sign) to any specified recipients which do
+not include an @-sign, so that each RCPT TO address is fully qualified.
+\(Some configurations of sendmail require this.)
+
+Don't bother to set this unless you have get an error like:
+       Sending failed; SMTP protocol error
+when sending mail, and the *trace of SMTP session to <somewhere>*
+buffer includes an exchange like:
+       RCPT TO: <someone>
+       501 <someone>: recipient address must contain a domain
+"
+  :type '(choice (const nil) string)
+  :group 'smtpmail)
+
+(defun maybe-append-domain (recipient)
+  (if (or (not smtpmail-sendto-domain)
+         (string-match "@" recipient))
+      recipient
+    (concat recipient "@" smtpmail-sendto-domain)))
+
 (defcustom smtpmail-debug-info nil
   "*smtpmail debug info printout. messages and process buffer."
   :type 'boolean
@@ -448,7 +473,7 @@ This is relative to `smtpmail-queue-dir'.")
            ;; RCPT TO: <recipient>
            (let ((n 0))
              (while (not (null (nth n recipient)))
-               (smtpmail-send-command process (format "RCPT TO: <%s>" (nth n recipient)))
+               (smtpmail-send-command process (format "RCPT TO: <%s>" (maybe-append-domain (nth n recipient))))
                (setq n (1+ n))
 
                (setq response-code (smtpmail-read-response process))