1 |
@c This is part of the Emacs manual. |
@c This is part of the Emacs manual. |
2 |
@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001 |
@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001, 2003 |
3 |
@c Free Software Foundation, Inc. |
@c Free Software Foundation, Inc. |
4 |
@c See file emacs.texi for copying conditions. |
@c See file emacs.texi for copying conditions. |
5 |
@node Sending Mail, Rmail, Picture, Top |
@node Sending Mail, Rmail, Picture, Top |
82 |
* Mode: Mail Mode. Special commands for editing mail being composed. |
* Mode: Mail Mode. Special commands for editing mail being composed. |
83 |
* Amuse: Mail Amusements. Distracting the NSA; adding fortune messages. |
* Amuse: Mail Amusements. Distracting the NSA; adding fortune messages. |
84 |
* Methods: Mail Methods. Using alternative mail-composition methods. |
* Methods: Mail Methods. Using alternative mail-composition methods. |
85 |
|
* SMTP: Sending via SMTP. Sending mail via SMTP. |
86 |
@end menu |
@end menu |
87 |
|
|
88 |
@node Mail Format |
@node Mail Format |
692 |
apply; the other methods use a different format of text in a different |
apply; the other methods use a different format of text in a different |
693 |
buffer, and their commands are different as well. |
buffer, and their commands are different as well. |
694 |
|
|
695 |
|
@node Sending via SMTP |
696 |
|
@section Sending via SMTP |
697 |
|
@cindex SMTP |
698 |
|
|
699 |
|
Emacs includes a package for sending your mail to a SMTP server and |
700 |
|
have it take care of delivering it to the final destination, rather |
701 |
|
than letting the MTA on your local system take care of it. This can |
702 |
|
be useful if you don't have a MTA set up on your host, or if your |
703 |
|
machine is often disconnected from the Internet. |
704 |
|
|
705 |
|
Sending mail via SMTP requires configuring your mail user agent |
706 |
|
(@pxref{Mail Methods}) to use the SMTP library. How to do this should |
707 |
|
be described for each mail user agent; for the Message and Gnus user |
708 |
|
agents the variable @code{message-send-mail-function} (@pxref{Mail |
709 |
|
Variables,,,message}) is used. |
710 |
|
|
711 |
|
@vindex send-mail-function |
712 |
|
The variable @code{send-mail-function} controls how the default mail |
713 |
|
user agent sends mail. It should be set to a function. The default |
714 |
|
is @code{sendmail-send-it}, but must be set to @code{smtpmail-send-it} |
715 |
|
in order to use the SMTP library. @code{feedmail-send-it} is another |
716 |
|
option. |
717 |
|
|
718 |
|
Before using SMTP you must find out the hostname of the SMTP server |
719 |
|
to use. Your system administrator should provide you with this |
720 |
|
information, but often it is the same as the server you receive mail |
721 |
|
from. |
722 |
|
|
723 |
|
@vindex smtpmail-smtp-server |
724 |
|
The variable @code{smtpmail-smtp-server} controls the hostname of |
725 |
|
the server to use. It is a string with an IP address or hostname. It |
726 |
|
defaults to the contents of the @code{SMTPSERVER} environment |
727 |
|
variable, or, if empty, the contents of |
728 |
|
@code{smtpmail-default-smtp-server}. |
729 |
|
|
730 |
|
@vindex smtpmail-default-smtp-server |
731 |
|
The variable @code{smtpmail-default-smtp-server} controls the |
732 |
|
default hostname of the server to use. It is a string with an IP |
733 |
|
address or hostname. It must be set before the SMTP library is |
734 |
|
loaded. It has no effect if set after the SMTP library has been |
735 |
|
loaded, or if @code{smtpmail-smtp-server} is defined. It is usually |
736 |
|
set by system administrators in a site wide initialization file. |
737 |
|
|
738 |
|
@cindex Mail Submission |
739 |
|
SMTP is normally used on the registered ``smtp'' TCP service port 25. |
740 |
|
Some environments use SMTP in ``Mail Submission'' mode, which uses |
741 |
|
port 587. Using other ports is not uncommon, either for security by |
742 |
|
obscurity purposes, port forwarding, or otherwise. |
743 |
|
|
744 |
|
@vindex smtpmail-smtp-service |
745 |
|
The variable @code{smtpmail-smtp-service} controls the port on the |
746 |
|
server to contact. It is either a string, in which case it will be |
747 |
|
translated into an integer using system calls, or an integer. |
748 |
|
|
749 |
|
Many environments require SMTP clients to authenticate themselves |
750 |
|
before they are allowed to route mail via a server. The two following |
751 |
|
variables contains the authentication information needed for this. |
752 |
|
The first variable, @code{smtpmail-auth-credentials}, instructs the |
753 |
|
SMTP library to use a SASL authentication step, currently only the |
754 |
|
CRAM-MD5, PLAIN and LOGIN-MD5 mechanisms are supported and will be |
755 |
|
selected in that order if the server supports them. The second |
756 |
|
variable, @code{smtpmail-starttls-credentials}, instructs the SMTP |
757 |
|
library to connect to the server using STARTTLS. This means the |
758 |
|
protocol exchange can be integrity protected and confidential by using |
759 |
|
TLS, and optionally also authentication of the client. It is common |
760 |
|
to use both these mechanisms, e.g. to use STARTTLS to achieve |
761 |
|
integrity and confidentiality and then use SASL for client |
762 |
|
authentication. |
763 |
|
|
764 |
|
@vindex smtpmail-auth-credentials |
765 |
|
The variable @code{smtpmail-auth-credentials} contains a list of |
766 |
|
hostname, port, username and password tuples. When the SMTP library |
767 |
|
connects to a host on a certain port, this variable is searched to |
768 |
|
find a matching entry for that hostname and port. If an entry is |
769 |
|
found, the authentication process is invoked and the credentials are |
770 |
|
used. The hostname field follows the same format as |
771 |
|
@code{smtpmail-smtp-server} (i.e., a string) and the port field the |
772 |
|
same format as @code{smtpmail-smtp-service} (i.e., a string or an |
773 |
|
integer). The username and password fields, which either can be |
774 |
|
@samp{nil} to indicate that the user is queried for the value |
775 |
|
interactively, should be strings with the username and password, |
776 |
|
respectively, information that is normally provided by system |
777 |
|
administrators. |
778 |
|
|
779 |
|
@vindex smtpmail-starttls-credentials |
780 |
|
The variable @code{smtpmail-starttls-credentials} contains a list of |
781 |
|
tuples with hostname, port, name of file containing client key, and |
782 |
|
name of file containing client certificate. The processing is similar |
783 |
|
to the previous variable. The client key and certificate may be |
784 |
|
@samp{nil} if you do not wish to use client authentication. The use |
785 |
|
of this variable requires the @samp{starttls} external program to be |
786 |
|
installed, you can get it from |
787 |
|
@samp{ftp://ftp.opaopa.org/pub/elisp/starttls-*.tar.gz}. |
788 |
|
|
789 |
|
The remaining variables are more esoteric and is normally not needed. |
790 |
|
|
791 |
|
@vindex smtpmail-debug-info |
792 |
|
The variable @code{smtpmail-debug-info} controls whether to print |
793 |
|
the SMTP protocol exchange in the minibuffer, and retain the entire |
794 |
|
exchange in a buffer @samp{*trace of SMTP session to |
795 |
|
mail.example.org*}. |
796 |
|
|
797 |
|
@vindex smtpmail-debug-verb |
798 |
|
The variable @code{smtpmail-debug-verb} controls whether to send the |
799 |
|
VERB token to the server. The VERB server instructs the server to be |
800 |
|
more verbose, and often also to attempt final delivery while your SMTP |
801 |
|
session is still running. It is usually only useful together with |
802 |
|
@code{smtpmail-debug-info}. Note that this may cause mail delivery to |
803 |
|
take considerable time if the final destination cannot accept mail. |
804 |
|
|
805 |
|
@vindex smtpmail-local-domain |
806 |
|
The variable @code{smtpmail-local-domain} controls the hostname sent |
807 |
|
in the first EHLO or HELO command sent to the server. It should only |
808 |
|
be set if the @code{system-name} function returns a name that isn't |
809 |
|
accepted by the server. Do not set this variable unless your server |
810 |
|
complains. |
811 |
|
|
812 |
|
@vindex smtpmail-sendto-domain |
813 |
|
The variable @code{smtpmail-sendto-domain} makes the SMTP library |
814 |
|
add @samp{@@} and the specified value to recipients specified in the |
815 |
|
message when they are sent using the RCPT TO command. Some |
816 |
|
configurations of sendmail requires this behaviour. Don't bother to |
817 |
|
set this unless you have get an error like: |
818 |
|
|
819 |
|
@example |
820 |
|
Sending failed; SMTP protocol error |
821 |
|
@end example |
822 |
|
|
823 |
|
when sending mail, and the *trace of SMTP session to <somewhere>* |
824 |
|
buffer (enabled via @code{smtpmail-debug-info}) includes an exchange |
825 |
|
like: |
826 |
|
|
827 |
|
@example |
828 |
|
RCPT TO: <someone> |
829 |
|
501 <someone>: recipient address must contain a domain |
830 |
|
@end example |
831 |
|
|
832 |
|
@vindex smtpmail-queue-mail |
833 |
|
The variable @code{smtpmail-queue-mail} controls whether a simple |
834 |
|
off line mail sender is active. This variable is a boolean, and |
835 |
|
defaults to @samp{nil} (disabled). If this is non-nil, mail is not |
836 |
|
sent immediately but rather queued in the directory |
837 |
|
@code{smtpmail-queue-dir} and can be later sent manually by invoking |
838 |
|
@code{smtpmail-send-queued-mail} (typically when you connect to the |
839 |
|
Internet). |
840 |
|
|
841 |
|
@vindex smtpmail-queue-dir |
842 |
|
The variable @code{smtpmail-queue-dir} specifies the name of the |
843 |
|
directory to hold queued messages. It defaults to |
844 |
|
@samp{~/Mail/queued-mail/}. |
845 |
|
|
846 |
|
@findex smtpmail-send-queued-mail |
847 |
|
The function @code{smtpmail-send-queued-mail} can be used to send |
848 |
|
any queued mail when @code{smtpmail-queue-mail} is enabled. It is |
849 |
|
typically invoked interactively with @kbd{M-x RET |
850 |
|
smtpmail-send-queued-mail RET} when you are connected to the Internet. |