;;; 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.
;;(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
: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
;; 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))