@cindex X-Message-SMTP-Method
If you have a complex @acronym{SMTP} setup, and want some messages to
go via one mail server, and other messages to go through another, you
-can use the @samp{X-Message-SMTP-Method} header. These are the
-supported values:
-
-@table @samp
-@item smtpmail
+can use the @samp{X-Message-SMTP-Method} header to override the
+default by using the keyword @samp{smtp} followed by the server
+information:
@example
X-Message-SMTP-Method: smtp smtp.fsf.org 587
name when authenticating. This is handy if you have several
@acronym{SMTP} accounts on the same server.
-@item sendmail
+This header may also be used to specify an alternative MTA by using a
+@samp{mailer} keyword, where @samp{mailer} is the name of an MTA with
+a corresponding @code{message-send-mail-with-'mailer'} function. For
+example:
@example
X-Message-SMTP-Method: sendmail
@end example
-This will send the message via the locally installed sendmail/exim/etc
-installation.
+will send the message via the locally installed sendmail program. The
+recognized values of @samp{mailer} are sendmail, qmail, mh, and
+mailclient.
-@end table
@item message-mh-deletable-headers
@vindex message-mh-deletable-headers
"Send the current buffer to `message-send-mail-function'.
Or, if there's a header that specifies a different method, use
that instead."
- (let ((method (message-field-value "X-Message-SMTP-Method")))
+ (let ((method (message-field-value "X-Message-SMTP-Method"))
+ send-function)
(if (not method)
- (funcall message-send-mail-function)
+ (funcall message-send-mail-function)
(message-remove-header "X-Message-SMTP-Method")
(setq method (split-string method))
+ (setq send-function
+ (symbol-function
+ (intern-soft (format "message-send-mail-with-%s" (car method)))))
(cond
- ((equal (car method) "sendmail")
- (message-send-mail-with-sendmail))
((equal (car method) "smtp")
- (require 'smtpmail)
- (let* ((smtpmail-store-queue-variables t)
+ (require 'smtpmail)
+ (let* ((smtpmail-store-queue-variables t)
(smtpmail-smtp-server (nth 1 method))
- (service (nth 2 method))
- (port (string-to-number service))
- ;; If we're talking to the TLS SMTP port, then force a
- ;; TLS connection.
- (smtpmail-stream-type (if (= port 465)
- 'tls
- smtpmail-stream-type))
- (smtpmail-smtp-service (if (> port 0) port service))
- (smtpmail-smtp-user (or (nth 3 method) smtpmail-smtp-user)))
- (message-smtpmail-send-it)))
+ (service (nth 2 method))
+ (port (string-to-number service))
+ ;; If we're talking to the TLS SMTP port, then force a
+ ;; TLS connection.
+ (smtpmail-stream-type (if (= port 465)
+ 'tls
+ smtpmail-stream-type))
+ (smtpmail-smtp-service (if (> port 0) port service))
+ (smtpmail-smtp-user (or (nth 3 method) smtpmail-smtp-user)))
+ (message-smtpmail-send-it)))
+ (send-function
+ (funcall send-function))
(t
- (error "Unknown method %s" method))))))
+ (error "Unknown mail method %s" method))))))
(defun message-send-mail-with-sendmail ()
"Send off the prepared buffer with sendmail."