This file documents Message, the Emacs message composition mode.

Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the license is included in the section entitled ``GNU Free Documentation License'' in the Emacs manual.

     (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify this GNU Manual, like GNU software.  Copies published by the Free Software Foundation raise funds for GNU development.''

     This document is part of a collection distributed under the GNU Free Documentation License.  If you want to distribute this document separately from the collection, you can do so by adding a copy of the license to the document, as described in section 6 of the license.

Message
*******

All message composition from Gnus (both mail and news) takes place in Message mode buffers.

This manual corresponds to Message v5.10.6.  Message is distributed with the Gnus distribution bearing the same version number as this manual.

Interface
*********

When a program (or a person) wants to respond to a message---reply, follow up, forward, cancel---the program (or person) should just put point in the buffer where the message is and call the required command. Message will then pop up a new message mode buffer with appropriate headers filled out, and the user can edit the message before sending it.

New Mail Message
================

The message-mail command pops up a new message buffer.

Two optional parameters are accepted: The first will be used as the To header and the second as the Subject header.  If these are nil, those two headers will be empty.

New News Message
================

The message-news command pops up a new message buffer.

This function accepts two optional parameters.  The first will be used as the Newsgroups header and the second as the Subject header.  If these are nil, those two headers will be empty.

Reply
=====

The message-reply function pops up a message buffer that's a reply to the message in the current buffer.

Message uses the normal methods to determine where replies are to go (see Responses), but you can change the behavior to suit your needs by fiddling with the message-reply-to-function variable.

If you want the replies to go to the Sender instead of the From, you could do something like this:

     (setq message-reply-to-function
           (lambda ()
            (cond ((equal (mail-fetch-field "from") "somebody")
                    (list (cons 'To (mail-fetch-field "sender"))))
                  (t
                   nil))))

This function will be called narrowed to the head of the article that is being replied to.

As you can see, this function should return a list.  In this case, it returns ((To . "Whom")) if it has an opinion as to what the To header should be.  If it does not, it should just return nil, and the normal methods for determining the To header will be used.

Each list element should be a cons, where the CAR should be the name of a header (e.g. Cc) and the CDR should be the header value (e.g. larsi@ifi.uio.no).  All these headers will be inserted into the head of the outgoing mail.

Wide Reply
==========

The message-wide-reply pops up a message buffer that's a wide reply to the message in the current buffer.  A wide reply is a reply that goes out to all people listed in the To, From (or Reply-to) and Cc headers.

Message uses the normal methods to determine where wide replies are to go, but you can change the behavior to suit your needs by fiddling with the message-wide-reply-to-function.  It is used in the same way as message-reply-to-function (see Reply).

Addresses that match the message-dont-reply-to-names regular expression will be removed from the Cc header.

If message-wide-reply-confirm-recipients is non-nil you will be asked to confirm that you want to reply to multiple recipients.  The default is nil.

Followup
========

The message-followup command pops up a message buffer that's a followup to the message in the current buffer.

Message uses the normal methods to determine where followups are to go, but you can change the behavior to suit your needs by fiddling with the message-followup-to-function.  It is used in the same way as message-reply-to-function (see Reply).

The message-use-followup-to variable says what to do about Followup-To headers.  If it is use, always use the value. If it is ask (which is the default), ask whether to use the value.  If it is t, use the value unless it is poster.  If it is nil, don't use the value.

Canceling News
==============

The message-cancel-news command cancels the article in the current buffer.

The value of message-cancel-message is inserted in the body of the cancel message.  The default is I am canceling my own article..

When Message posts news messages, it inserts Cancel-Lock headers by default.  This is a cryptographic header that ensures that only you can cancel your own messages, which is nice.  The downside is that if you lose your .emacs file (which is where Gnus stores the secret cancel lock password (which is generated automatically the first time you use this feature)), you won't be able to cancel your message.  If you want to manage a password yourself, you can put something like the following in your ~/.gnus.el file:

     (setq canlock-password "geheimnis"
           canlock-password-for-verify canlock-password)

Whether to insert the header or not is controlled by the message-insert-canlock variable.

Not many news servers respect the Cancel-Lock header yet, but this is expected to change in the future.

Superseding
===========

The message-supersede command pops up a message buffer that will supersede the message in the current buffer.

Headers matching the message-ignored-supersedes-headers are removed before popping up the new message buffer.  The default is

^Path:\\|^Date\\|^NNTP-Posting-Host:\\|^Xref:\\|^Lines:\\|

^Received:\\|^X-From-Line:\\|Return-Path:\\|^Supersedes:.

Forwarding
==========

The message-forward command pops up a message buffer to forward the message in the current buffer.  If given a prefix, forward using news.

message-forward-ignored-headers
     All headers that match this regexp will be deleted when forwarding a message.

message-make-forward-subject-function
     A list of functions that are called to generate a subject header for forwarded messages.  The subject generated by the previous function is passed into each successive function.

     The provided functions are:

     message-forward-subject-author-subject
          Source of article (author or newsgroup), in brackets followed by the subject.

     message-forward-subject-fwd
          Subject of article with Fwd: prepended to it.

message-wash-forwarded-subjects
     If this variable is t, the subjects of forwarded messages have the evidence of previous forwards (such as Fwd:, Re:, (fwd)) removed before the new subject is constructed.  The default value is nil.

message-forward-as-mime
     If this variable is t (the default), forwarded messages are included as inline MIME RFC822 parts.  If it's nil, forwarded messages will just be copied inline to the new message, like previous, non MIME-savvy versions of Gnus would do.

message-forward-before-signature
     If non-nil, put forwarded message before signature, else after.

Resending
=========

The message-resend command will prompt the user for an address and resend the message in the current buffer to that address.

Headers that match the message-ignored-resent-headers regexp will be removed before sending the message.

Bouncing
========

The message-bounce command will, if the current buffer contains a bounced mail message, pop up a message buffer stripped of the bounce information.  A bounced message is typically a mail you've sent out that has been returned by some mailer-daemon as undeliverable.

Headers that match the message-ignored-bounced-headers regexp will be removed before popping up the buffer.  The default is ^\\(Received\\|Return-Path\\):.

Mailing Lists
=============

Sometimes while posting to mailing lists, the poster needs to direct followups to the post to specific places.  The Mail-Followup-To (MFT) was created to enable just this.  Two example scenarios where this is useful:

  * A mailing list poster can use MFT to express that responses should be sent to just the list, and not the poster as well.  This will happen if the poster is already subscribed to the list.

  * A mailing list poster can use MFT to express that responses should be sent to the list and the poster as well.  This will happen if the poster is not subscribed to the list.

  * If a message is posted to several mailing lists, MFT may also be used to direct the following discussion to one list only, because discussions that are spread over several lists tend to be fragmented and very difficult to follow.

Gnus honors the MFT header in other's messages (i.e. while following up to someone else's post) and also provides support for generating sensible MFT headers for outgoing messages as well.

Composing a correct MFT header automagically
--------------------------------------------

The first step in getting Gnus to automagically generate a MFT header in posts you make is to give Gnus a list of the mailing lists addresses you are subscribed to.  You can do this in more than one way.  The following variables would come in handy.

message-subscribed-addresses
     This should be a list of addresses the user is subscribed to.  Its default value is nil.  Example:

          (setq message-subscribed-addresses
                '("ding@gnus.org" "bing@noose.org"))

message-subscribed-regexps
     This should be a list of regexps denoting the addresses of mailing lists subscribed to.  Default value is nil.  Example: If you want to achieve the same result as above:

          (setq message-subscribed-regexps
                '("\\(ding@gnus\\)\\|\\(bing@noose\\)\\.org")

message-subscribed-address-functions
     This can be a list of functions to be called (one at a time!!) to determine the value of MFT headers.  It is advisable that these functions not take any arguments.  Default value is nil.

     There is a pre-defined function in Gnus that is a good candidate for this variable.  gnus-find-subscribed-addresses is a function that returns a list of addresses corresponding to the groups that have the subscribed (see Group Parameters (The Gnus Manual)) group parameter set to a non-nil value. This is how you would do it.

          (setq message-subscribed-address-functions
                '(gnus-find-subscribed-addresses))

message-subscribed-address-file
     You might be one organized human freak and have a list of addresses of all subscribed mailing lists in a separate file!  Then you can just set this variable to the name of the file and life would be good.

You can use one or more of the above variables.  All their values are ``added'' in some way that works :-)

Now you are all set.  Just start composing a message as you normally do. And just send it; as always.  Just before the message is sent out, Gnus' MFT generation thingy kicks in and checks if the message already has a MFT field.  If there is one, it is left alone.  (Except if it's empty - in that case, the field is removed and is not replaced with an automatically generated one.  This lets you disable MFT generation on a per-message basis.)  If there is none, then the list of recipient addresses (in the To: and Cc: headers) is checked to see if one of them is a list address you are subscribed to.  If none of them is a list address, then no MFT is generated; otherwise, a MFT is added to the other headers and set to the value of all addresses in To: and Cc:

Hm.  ``So'', you ask, ``what if I send an email to a list I am not subscribed to?  I want my MFT to say that I want an extra copy.''  (This is supposed to be interpreted by others the same way as if there were no MFT, but you can use an explicit MFT to override someone else's to-address group parameter.)  The function message-generate-unsubscribed-mail-followup-to might come in handy.  It is bound to C-c C-f C-a by default.  In any case, you can insert a MFT of your own choice; C-c C-f C-m (message-goto-mail-followup-to) will help you get started.

Honoring an MFT post
--------------------

When you followup to a post on a mailing list, and the post has a MFT header, Gnus' action will depend on the value of the variable message-use-mail-followup-to.  This variable can be one of:

use
     Always honor MFTs.  The To: and Cc: headers in your followup will be derived from the MFT header of the original post.  This is the default.

nil
     Always dishonor MFTs (just ignore the darned thing)

ask
     Gnus will prompt you for an action.

It is considered good netiquette to honor MFT, as it is assumed the fellow who posted a message knows where the followups need to go better than you do.

Commands
********

Buffer Entry
============

You most often end up in a Message buffer when responding to some other message of some sort.  Message does lots of handling of quoted text, and may remove signatures, reformat the text, or the like---depending on which used settings you're using.  Message usually gets things right, but sometimes it stumbles.  To help the user unwind these stumblings, Message sets the undo boundary before each major automatic action it takes.  If you press the undo key (usually located at C-_) a few times, you will get back the un-edited message you're responding to.

Header Commands
===============

Commands for moving to headers
------------------------------

These following commands move to the header in question.  If it doesn't exist, it will be inserted.

C-c ?
     Describe the message mode.

C-c C-f C-t
     Go to the To header (message-goto-to).

C-c C-f C-o
     Go to the From header (message-goto-from).  (The ``o'' in the key binding is for Originator.)

C-c C-f C-b
     Go to the Bcc header (message-goto-bcc).

C-c C-f C-f
     Go to the Fcc header (message-goto-fcc).

C-c C-f C-c
     Go to the Cc header (message-goto-cc).

C-c C-f C-s
     Go to the Subject header (message-goto-subject).

C-c C-f C-r
     Go to the Reply-To header (message-goto-reply-to).

C-c C-f C-n
     Go to the Newsgroups header (message-goto-newsgroups).

C-c C-f C-d
     Go to the Distribution header (message-goto-distribution).

C-c C-f C-o
     Go to the Followup-To header (message-goto-followup-to).

C-c C-f C-k
     Go to the Keywords header (message-goto-keywords).

C-c C-f C-u
     Go to the Summary header (message-goto-summary).

C-c C-f C-i
     This inserts the Importance: header with a value of high.  This header is used to signal the importance of the message to the receiver.  If the header is already present in the buffer, it cycles between the three valid values according to RFC 1376: low, normal and high.

C-c C-f C-a
     Insert a reasonable Mail-Followup-To: header (see Mailing Lists) in a post to an unsubscribed list.  When making original posts to a mailing list you are not subscribed to, you have to type in a Mail-Followup-To: header by hand.  The contents, usually, are the addresses of the list and your own address.  This function inserts such a header automatically.  It fetches the contents of the To: header in the current mail buffer, and appends the current user-mail-address.

     If the optional argument include-cc is non-nil, the addresses in the Cc: header are also put into the Mail-Followup-To: header.

Commands to change headers
--------------------------

C-c C-o
     Sort headers according to message-header-format-alist (message-sort-headers).

C-c C-t
     Insert a To header that contains the Reply-To or From header of the message you're following up (message-insert-to).

C-c C-n
     Insert a Newsgroups header that reflects the Followup-To or Newsgroups header of the article you're replying to (message-insert-newsgroups).

C-c C-l
     Send a message to the list only.  Remove all addresses but the list address from To: and Cc: headers.

C-c M-n
     Insert a request for a disposition notification.  (message-insert-disposition-notification-to). This means that if the recipient support RFC 2298 she might send you a notification that she received the message.

M-x message-insert-importance-high
     Insert an Importance header with a value of high, deleting headers if necessary.

M-x message-insert-importance-low
     Insert an Importance header with a value of low, deleting headers if necessary.

C-c C-f s
     Change the current Subject header.  Ask for new Subject header and append (was: <Old Subject>).  The old subject can be stripped on replying, see message-subject-trailing-was-query (see Message Headers).

C-c C-f x
     Ask for an additional Newsgroups and FollowUp-To for a cross-post.  message-cross-post-followup-to mangles FollowUp-To and Newsgroups header to point to group. If message-cross-post-default is nil or if called with a prefix-argument Follow-Up is set, but the message is not cross-posted.

C-c C-f t
     Replace contents of To header with contents of Cc or Bcc header.

C-c C-f w
     Insert To and Cc headers as if you were doing a wide reply.

C-c C-f a
     Insert X-No-Archive: Yes in the header and a note in the body. The header and the note can be customized using message-archive-header and message-archive-note.  When called with a prefix argument, ask for a text to insert.  If you don't want the note in the body, set message-archive-note to nil.

Movement
========

C-c C-b
     Move to the beginning of the body of the message (message-goto-body).

C-c C-i
     Move to the signature of the message (message-goto-signature).

C-a
     If at beginning of header value, go to beginning of line, else go to beginning of header value.  (The header value comes after the header name and the colon.)  This behavior can be disabled by toggling the variable message-beginning-of-line.

Insertion
=========

C-c C-y
     Yank the message that's being replied to into the message buffer (message-yank-original).

C-c C-M-y
     Prompt for a buffer name and yank the contents of that buffer into the message buffer (message-yank-buffer).

C-c C-q
     Fill the yanked message (message-fill-yanked-message).  Warning: Can severely mess up the yanked text if its quoting conventions are strange.  You'll quickly get a feel for when it's safe, though.  Anyway, just remember that C-x u (undo) is available and you'll be all right.

C-c C-w
     Insert a signature at the end of the buffer (message-insert-signature).

C-c M-h
     Insert the message headers (message-insert-headers).

C-c M-m
     Mark some region in the current article with enclosing tags.  See message-mark-insert-begin and message-mark-insert-end. When called with a prefix argument, use slrn style verbatim marks (#v+ and #v-).

C-c M-f
     Insert a file in the current article with enclosing tags. See message-mark-insert-begin and message-mark-insert-end. When called with a prefix argument, use slrn style verbatim marks (#v+ and #v-).

MIME
====

Message is a MIME-compliant posting agent.  The user generally doesn't have to do anything to make the MIME happen---Message will automatically add the Content-Type and Content-Transfer-Encoding headers.

The most typical thing users want to use the multipart things in MIME for is to add ``attachments'' to mail they send out. This can be done with the C-c C-a command, which will prompt for a file name and a MIME type.

If your Emacs supports drag and drop, you can also drop the file in the Message buffer.  The variable mml-dnd-protocol-alist specifies what kind of action is done when you drop a file into the Message buffer.  The variable mml-dnd-attach-options controls which MIME options you want to specify when dropping a file.  If it is a list, valid members are type, description and disposition.  disposition implies type.  If it is nil, don't ask for options.  If it is t, ask the user whether or not to specify options.

You can also create arbitrarily complex multiparts using the MML language (see Composing (The Emacs MIME Manual)).

IDNA
====

Message is a IDNA-compliant posting agent.  The user generally doesn't have to do anything to make the IDNA happen---Message will encode non-ASCII domain names in From, To, and Cc headers automatically.

Until IDNA becomes more well known, Message queries you whether IDNA encoding of the domain name really should occur.  Some users might not be aware that domain names can contain non-ASCII now, so this gives them a safety net if they accidently typed a non-ASCII domain name.

The message-use-idna variable control whether IDNA is used.  If the variable is nil no IDNA encoding will ever happen, if it is set to the symbol ask the user will be queried, and if set to t IDNA encoding happens automatically (the default).

If you want to experiment with the IDNA encoding, you can invoke M-x message-idna-to-ascii-rhs RET in the message buffer to have the non-ASCII domain names encoded while you edit the message.

Note that you must have GNU Libidn (http://www.gnu.org/software/libidn/) installed in order to use this functionality.

Security
========

Using the MML language, Message is able to create digitally signed and digitally encrypted messages.  Message (or rather MML) currently support PGP (RFC 1991), PGP/MIME (RFC 2015/3156) and S/MIME.  Instructing MML to perform security operations on a MIME part is done using the C-c C-m s key map for signing and the C-c C-m c key map for encryption, as follows.

C-c C-m s s

     Digitally sign current message using S/MIME.

C-c C-m s o

     Digitally sign current message using PGP.

C-c C-m s p

     Digitally sign current message using PGP/MIME.

C-c C-m c s

     Digitally encrypt current message using S/MIME.

C-c C-m c o

     Digitally encrypt current message using PGP.

C-c C-m c p

     Digitally encrypt current message using PGP/MIME.

C-c C-m C-n
     Remove security related MML tags from message.

These commands do not immediately sign or encrypt the message, they merely insert the proper MML secure tag to instruct the MML engine to perform that operation when the message is actually sent.  They may perform other operations too, such as locating and retrieving a S/MIME certificate of the person you wish to send encrypted mail to.  When the mml parsing engine converts your MML into a properly encoded MIME message, the secure tag will be replaced with either a part or a multipart tag.  If your message contains other mml parts, a multipart tag will be used; if no other parts are present in your message a single part tag will be used. This way, message mode will do the Right Thing (TM) with signed/encrypted multipart messages.

Since signing and especially encryption often is used when sensitive information is sent, you may want to have some way to ensure that your mail is actually signed or encrypted.  After invoking the above sign/encrypt commands, it is possible to preview the raw article by using C-u C-c RET P (mml-preview).  Then you can verify that your long rant about what your ex-significant other or whomever actually did with that funny looking person at that strange party the other night, actually will be sent encrypted.

Note!  Neither PGP/MIME nor S/MIME encrypt/signs RFC822 headers.  They only operate on the MIME object.  Keep this in mind before sending mail with a sensitive Subject line.

By default, when encrypting a message, Gnus will use the ``signencrypt'' mode, which means the message is both signed and encrypted.  If you would like to disable this for a particular message, give the mml-secure-message-encrypt-* command a prefix argument, e.g., C-u C-c C-m c p.

Actually using the security commands above is not very difficult.  At least not compared with making sure all involved programs talk with each other properly.  Thus, we now describe what external libraries or programs are required to make things work, and some small general hints.

Using S/MIME
------------

Note!  This section assume you have a basic familiarity with modern cryptography, S/MIME, various PKCS standards, OpenSSL and so on.

The S/MIME support in Message (and MML) require OpenSSL.  OpenSSL performs the actual S/MIME sign/encrypt operations.  OpenSSL can be found at http://www.openssl.org/. OpenSSL 0.9.6 and later should work.  Version 0.9.5a cannot extract mail addresses from certificates, and it insert a spurious CR character into MIME separators so you may wish to avoid it if you would like to avoid being regarded as someone who send strange mail.  (Although by sending S/MIME messages you've probably already lost that contest.)

To be able to send encrypted mail, a personal certificate is not required.  Message (MML) need a certificate for the person to whom you wish to communicate with though.  You're asked for this when you type C-c C-m c s.  Currently there are two ways to retrieve this certificate, from a local file or from DNS.  If you chose a local file, it need to contain a X.509 certificate in PEM format. If you chose DNS, you're asked for the domain name where the certificate is stored, the default is a good guess.  To my belief, Message (MML) is the first mail agent in the world to support retrieving S/MIME certificates from DNS, so you're not likely to find very many certificates out there.  At least there should be one, stored at the domain simon.josefsson.org.  LDAP is a more popular method of distributing certificates, support for it is planned.  (Meanwhile, you can use ldapsearch from the command line to retrieve a certificate into a file and use it.)

As for signing messages, OpenSSL can't perform signing operations without some kind of configuration.  Especially, you need to tell it where your private key and your certificate is stored.  MML uses an Emacs interface to OpenSSL, aptly named smime.el, and it contain a custom group used for this configuration.  So, try M-x customize-group RET smime RET and look around.

Currently there is no support for talking to a CA (or RA) to create your own certificate.  None is planned either.  You need to do this manually with OpenSSL or using some other program.  I used Netscape and got a free S/MIME certificate from one of the big CA's on the net.  Netscape is able to export your private key and certificate in PKCS #12 format.  Use OpenSSL to convert this into a plain X.509 certificate in PEM format as follows.

     $ openssl pkcs12 -in ns.p12 -clcerts -nodes > key+cert.pem

The key+cert.pem file should be pointed to from the smime-keys variable.  You should now be able to send signed mail.

Note!  Your private key is now stored unencrypted in the file, so take care in handling it.  Storing encrypted keys on the disk are supported, and Gnus will ask you for a passphrase before invoking OpenSSL.  Read the OpenSSL documentation for how to achieve this.  If you use unencrypted keys (e.g., if they are on a secure storage, or if you are on a secure single user machine) simply press RET at the passphrase prompt.

Using PGP/MIME
--------------

PGP/MIME requires an external OpenPGP implementation, such as GNU Privacy Guard (http://www.gnupg.org/).  Pre-OpenPGP implementations such as PGP 2.x and PGP 5.x are also supported.  One Emacs interface to the PGP implementations, PGG (see PGG (PGG Manual)), is included, but Mailcrypt and Florian Weimer's gpg.el are also supported.

Note, if you are using the gpg.el you must make sure that the directory specified by gpg-temp-directory have permissions 0700.

Creating your own key is described in detail in the documentation of your PGP implementation, so we refer to it.

If you have imported your old PGP 2.x key into GnuPG, and want to send signed and encrypted messages to your fellow PGP 2.x users, you'll discover that the receiver cannot understand what you send. One solution is to use PGP 2.x instead (i.e., if you use pgg, set pgg-default-scheme to pgp).  If you do want to use GnuPG, you can use a compatibility script called gpg-2comp available from http://muppet.faveve.uni-stuttgart.de/~gero/gpg-2comp/.  You could also convince your fellow PGP 2.x users to convert to GnuPG. As a final workaround, you can make the sign and encryption work in two steps; separately sign, then encrypt a message.  If you would like to change this behavior you can customize the mml-signencrypt-style-alist variable.  For example:

     (setq mml-signencrypt-style-alist '(("smime" separate)
                                         ("pgp" separate)
                                         ("pgpauto" separate)
                                         ("pgpmime" separate)))

This causes to sign and encrypt in two passes, thus generating a message that can be understood by PGP version 2.

(Refer to http://www.gnupg.org/gph/en/pgp2x.html for more information about the problem.)

Various Commands
================

C-c C-r
     Caesar rotate (aka. rot13) the current message (message-caesar-buffer-body).  If narrowing is in effect, just rotate the visible portion of the buffer.  A numerical prefix says how many places to rotate the text.  The default is 13.

C-c C-e
     Elide the text between point and mark (message-elide-region). The text is killed and replaced with the contents of the variable message-elide-ellipsis.  The default value is to use an ellipsis ([...]).

C-c M-k
     Kill the address under point.

C-c C-z
     Kill all the text up to the signature, or if that's missing, up to the end of the message (message-kill-to-signature).

C-c C-v
     Delete all text in the body of the message that is outside the region (message-delete-not-region).

M-RET
     Insert four newlines, and then reformat if inside quoted text.

     Here's an example:

          > This is some quoted text.  And here's more quoted text.

     If point is before And and you press M-RET, you'll get:

          > This is some quoted text.

          *

          > And here's more quoted text.

     * says where point will be placed.

C-c M-r
     Rename the buffer (message-rename-buffer).  If given a prefix, prompt for a new buffer name.

TAB
     If non-nil execute the function specified in message-tab-body-function.  Otherwise use the function bound to TAB in text-mode-map or global-map.

Sending
=======

C-c C-c
     Send the message and bury the current buffer (message-send-and-exit).

C-c C-s
     Send the message (message-send).

C-c C-d
     Bury the message buffer and exit (message-dont-send).

C-c C-k
     Kill the message buffer and exit (message-kill-buffer).

Mail Aliases
============

The message-mail-alias-type variable controls what type of mail alias expansion to use.  Currently only one form is supported---Message uses mailabbrev to handle mail aliases.  If this variable is nil, no mail alias expansion will be performed.

mailabbrev works by parsing the /etc/mailrc and ~/.mailrc files.  These files look like:

     alias lmi "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
     alias ding "ding@ifi.uio.no (ding mailing list)"

After adding lines like this to your ~/.mailrc file, you should be able to just write lmi in the To or Cc (and so on) headers and press SPC to expand the alias.

No expansion will be performed upon sending of the message---all expansions have to be done explicitly.

Spelling
========

There are two popular ways to have Emacs spell-check your messages: ispell and flyspell.  ispell is the older and probably more popular package.  You typically first write the message, and then run the entire thing through ispell and fix all the typos.  To have this happen automatically when you send a message, put something like the following in your .emacs file:

     (add-hook 'message-send-hook 'ispell-message)

If you're in the habit of writing in different languages, this can be controlled by the ispell-message-dictionary-alist variable:

     (setq ispell-message-dictionary-alist
           '(("^Newsgroups:.*\\bde\\." . "deutsch8")
             (".*" . "default")))

ispell depends on having the external ispell command installed.

The other popular method is using flyspell.  This package checks your spelling while you're writing, and marks any mis-spelled words in various ways.

To use flyspell, put something like the following in your .emacs file:

     (defun my-message-setup-routine ()
       (flyspell-mode 1))
     (add-hook 'message-setup-hook 'my-message-setup-routine)

flyspell depends on having the external ispell command installed.

Variables
*********

Message Headers
===============

Message is quite aggressive on the message generation front.  It has to be---it's a combined news and mail agent.  To be able to send combined messages, it has to generate all headers itself (instead of letting the mail/news system do it) to ensure that mail and news copies of messages look sufficiently similar.

message-generate-headers-first
     If t, generate all required headers before starting to compose the message.  This can also be a list of headers to generate:

          (setq message-generate-headers-first
                '(References))

     The variables message-required-headers, message-required-mail-headers and message-required-news-headers specify which headers are required.

     Note that some headers will be removed and re-generated before posting, because of the variable message-deletable-headers (see below).

message-draft-headers
     When running Message from Gnus, the message buffers are associated with a draft group.  message-draft-headers says which headers should be generated when a draft is written to the draft group.

message-from-style
     Specifies how From headers should look.  There are four valid values:

     nil
          Just the address---king@grassland.com.

     parens
          king@grassland.com (Elvis Parsley).

     angles
          Elvis Parsley <king@grassland.com>.

     default
          Look like angles if that doesn't require quoting, and parens if it does.  If even parens requires quoting, use angles anyway.

message-deletable-headers
     Headers in this list that were previously generated by Message will be deleted before posting.  Let's say you post an article.  Then you decide to post it again to some other group, you naughty boy, so you jump back to the *post-buf* buffer, edit the Newsgroups line, and ship it off again.  By default, this variable makes sure that the old generated Message-ID is deleted, and a new one generated.  If this isn't done, the entire empire would probably crumble, anarchy would prevail, and cats would start walking on two legs and rule the world. Allegedly.

message-default-headers
     This string is inserted at the end of the headers in all message buffers.

message-subject-re-regexp
     Responses to messages have subjects that start with Re: .  This is not an abbreviation of the English word ``response'', but is Latin, and means ``in response to''.  Some illiterate nincompoops have failed to grasp this fact, and have ``internationalized'' their software to use abominations like Aw:  (``antwort'') or Sv: (``svar'') instead, which is meaningless and evil.  However, you may have to deal with users that use these evil tools, in which case you may set this variable to a regexp that matches these prefixes.  Myself, I just throw away non-compliant mail.

     Here's an example of a value to deal with these headers when responding to a message:

          (setq message-subject-re-regexp
                (concat
                 "^[ \t]*"
                   "\\("
                     "\\("
                       "[Aa][Nn][Tt][Ww]\\.?\\|"     ; antw
                       "[Aa][Ww]\\|"                 ; aw
                       "[Ff][Ww][Dd]?\\|"            ; fwd
                       "[Oo][Dd][Pp]\\|"             ; odp
                       "[Rr][Ee]\\|"                 ; re
                       "[Rr][\311\351][Ff]\\.?\\|"   ; ref
                       "[Ss][Vv]"                    ; sv
                     "\\)"
                     "\\(\\[[0-9]*\\]\\)"
                     "*:[ \t]*"
                   "\\)"
                 "*[ \t]*"
                 ))

message-subject-trailing-was-query
     Controls what to do with trailing (was: <old subject>) in subject lines.  If nil, leave the subject unchanged.  If it is the symbol ask, query the user what do do.  In this case, the subject is matched against message-subject-trailing-was-ask-regexp.  If message-subject-trailing-was-query is t, always strip the trailing old subject.  In this case, message-subject-trailing-was-regexp is used.

message-alternative-emails
     Regexp matching alternative email addresses.  The first address in the To, Cc or From headers of the original article matching this variable is used as the From field of outgoing messages, replacing the default From value.

     For example, if you have two secondary email addresses john@home.net and john.doe@work.com and want to use them in the From field when composing a reply to a message addressed to one of them, you could set this variable like this:

          (setq message-alternative-emails
                (regexp-opt '("john@home.net" "john.doe@work.com")))

     This variable has precedence over posting styles and anything that runs off message-setup-hook.

message-allow-no-recipients
     Specifies what to do when there are no recipients other than Gcc or Fcc.  If it is always, the posting is allowed.  If it is never, the posting is not allowed.  If it is ask (the default), you are prompted.

message-hidden-headers
     A regexp, a list of regexps, or a list where the first element is not and the rest are regexps.  It says which headers to keep hidden when composing a message.

          (setq message-hidden-headers
                '(not "From" "Subject" "To" "Cc" "Newsgroups"))

     Headers are hidden using narrowing, you can use M-x widen to expose them in the buffer.

message-header-synonyms
     A list of lists of header synonyms.  E.g., if this list contains a member list with elements Cc and To, then message-carefully-insert-headers will not insert a To header when the message is already Cced to the recipient.

Mail Headers
============

message-required-mail-headers
     See News Headers, for the syntax of this variable.  It is (From Date Subject (optional . In-Reply-To) Message-ID Lines (optional . User-Agent)) by default.

message-ignored-mail-headers
     Regexp of headers to be removed before mailing.  The default is ^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:.

message-default-mail-headers
     This string is inserted at the end of the headers in all message buffers that are initialized as mail.

message-generate-hashcash
     Boolean variable that indicate whether X-Hashcash headers should be computed for the message.  See Hashcash (The Gnus Manual).

Mail Variables
==============

message-send-mail-function
     Function used to send the current buffer as mail.  The default is message-send-mail-with-sendmail, or smtpmail-send-it according to the system.  Other valid values include message-send-mail-with-mh, message-send-mail-with-qmail, message-smtpmail-send-it and feedmail-send-it.

message-mh-deletable-headers
     Most versions of MH doesn't like being fed messages that contain the headers in this variable.  If this variable is non-nil (which is the default), these headers will be removed before mailing when sending messages via MH.  Set it to nil if your MH can handle these headers.

message-qmail-inject-program
     Location of the qmail-inject program.

message-qmail-inject-args
     Arguments passed to qmail-inject programs. This should be a list of strings, one string for each argument.  It may also be a function.

     For e.g., if you wish to set the envelope sender address so that bounces go to the right place or to deal with listserv's usage of that address, you might set this variable to '("-f" "you@some.where").

message-sendmail-f-is-evil
     Non-nil means don't add -f username to the sendmail command line.  Doing so would be even more evil than leaving it out.

message-sendmail-envelope-from
     When message-sendmail-f-is-evil is nil, this specifies the address to use in the SMTP envelope.  If it is nil, use user-mail-address.  If it is the symbol header, use the From header of the message.

message-mailer-swallows-blank-line
     Set this to non-nil if the system's mailer runs the header and body together.  (This problem exists on SunOS 4 when sendmail is run in remote mode.)  The value should be an expression to test whether the problem will actually occur.

message-send-mail-partially-limit
     The limitation of messages sent as message/partial.  The lower bound of message size in characters, beyond which the message should be sent in several parts.  If it is nil, the size is unlimited.

News Headers
============

message-required-news-headers a list of header symbols.  These headers will either be automatically generated, or, if that's impossible, they will be prompted for.  The following symbols are valid:

From
     This required header will be filled out with the result of the message-make-from function, which depends on the message-from-style, user-full-name, user-mail-address variables.

Subject
     This required header will be prompted for if not present already.

Newsgroups
     This required header says which newsgroups the article is to be posted to.  If it isn't present already, it will be prompted for.

Organization
     This optional header will be filled out depending on the message-user-organization variable. message-user-organization-file will be used if this variable is t.  This variable can also be a string (in which case this string will be used), or it can be a function (which will be called with no parameters and should return a string to be used).

Lines
     This optional header will be computed by Message.

Message-ID
     This required header will be generated by Message.  A unique ID will be created based on the date, time, user name (for the local part) and the domain part.  For the domain part, message will look (in this order) at message-user-fqdn, system-name, mail-host-address and message-user-mail-address (i.e. user-mail-address) until a probably valid fully qualified domain name (FQDN) was found.

User-Agent
     This optional header will be filled out according to the message-newsreader local variable.

In-Reply-To
     This optional header is filled out using the Date and From header of the article being replied to.

Expires
     This extremely optional header will be inserted according to the message-expires variable.  It is highly deprecated and shouldn't be used unless you know what you're doing.

Distribution
     This optional header is filled out according to the message-distribution-function variable.  It is a deprecated and much misunderstood header.

Path
     This extremely optional header should probably never be used. However, some very old servers require that this header is present.  message-user-path further controls how this Path header is to look.  If it is nil, use the server name as the leaf node.  If it is a string, use the string.  If it is neither a string nor nil, use the user name only.  However, it is highly unlikely that you should need to fiddle with this variable at all.

In addition, you can enter conses into this list.  The CAR of this cons should be a symbol.  This symbol's name is the name of the header, and the CDR can either be a string to be entered verbatim as the value of this header, or it can be a function to be called.  This function should return a string to be inserted.  For instance, if you want to insert Mime-Version: 1.0, you should enter (Mime-Version . "1.0") into the list.  If you want to insert a funny quote, you could enter something like (X-Yow . yow) into the list.  The function yow will then be called without any arguments.

If the list contains a cons where the CAR of the cons is optional, the CDR of this cons will only be inserted if it is non-nil.

If you want to delete an entry from this list, the following Lisp snippet might be useful.  Adjust accordingly if you want to remove another element.

     (setq message-required-news-headers
           (delq 'Message-ID message-required-news-headers))

Other variables for customizing outgoing news articles:

message-syntax-checks
     Controls what syntax checks should not be performed on outgoing posts. To disable checking of long signatures, for instance, add

          (signature . disabled)

     to this list.

     Valid checks are:

     subject-cmsg
          Check the subject for commands.

     sender
          Insert a new Sender header if the From header looks odd.

     multiple-headers
          Check for the existence of multiple equal headers.

     sendsys
          Check for the existence of version and sendsys commands.

     message-id
          Check whether the Message-ID looks ok.

     from
          Check whether the From header seems nice.

     long-lines
          Check for too long lines.

     control-chars
          Check for invalid characters.

     size
          Check for excessive size.

     new-text
          Check whether there is any new text in the messages.

     signature
          Check the length of the signature.

     approved
          Check whether the article has an Approved header, which is something only moderators should include.

     empty
          Check whether the article is empty.

     invisible-text
          Check whether there is any invisible text in the buffer.

     empty-headers
          Check whether any of the headers are empty.

     existing-newsgroups
          Check whether the newsgroups mentioned in the Newsgroups and Followup-To headers exist.

     valid-newsgroups
          Check whether the Newsgroups and Followup-to headers are valid syntactically.

     repeated-newsgroups
          Check whether the Newsgroups and Followup-to headers contains repeated group names.

     shorten-followup-to
          Check whether to add a Followup-to header to shorten the number of groups to post to.

     All these conditions are checked by default.

message-ignored-news-headers
     Regexp of headers to be removed before posting.  The default is

     ^NNTP-Posting-Host:\\|^Xref:\\|^[BGF]cc:\\|^Resent-Fcc:\\|^X-Draft-From:.

message-default-news-headers
     This string is inserted at the end of the headers in all message buffers that are initialized as news.

News Variables
==============

message-send-news-function
     Function used to send the current buffer as news.  The default is message-send-news.

message-post-method
     Gnusish select method (see the Gnus manual for details) used for posting a prepared news message.

Insertion Variables
===================

message-ignored-cited-headers
     All headers that match this regexp will be removed from yanked messages.  The default is ., which means that all headers will be removed.

message-cite-prefix-regexp
     Regexp matching the longest possible citation prefix on a line.

message-citation-line-function
     Function called to insert the citation line.  The default is message-insert-citation-line, which will lead to citation lines that look like:

          Hallvard B Furuseth <h.b.furuseth@usit.uio.no> writes:

     Point will be at the beginning of the body of the message when this function is called.

     Note that Gnus provides a feature where clicking on `writes:' hides the cited text.  If you change the citation line too much, readers of your messages will have to adjust their Gnus, too.  See the variable gnus-cite-attribution-suffix.  See Article Highlighting (The Gnus Manual), for details.

message-yank-prefix
     When you are replying to or following up an article, you normally want to quote the person you are answering.  Inserting quoted text is done by yanking, and each line you yank will have message-yank-prefix prepended to it (except for quoted lines which use message-yank-cited-prefix and empty lines which use message-yank-empty-prefix).  The default is > .

message-yank-cited-prefix
     When yanking text from an article which contains already cited text, each line will be prefixed with the contents of this variable.  The default is >.  See also message-yank-prefix.

message-yank-empty-prefix
     When yanking text from an article, each empty line will be prefixed with the contents of this variable.  The default is >.  You can set this variable to an empty string to split the cited text into paragraphs automatically.  See also message-yank-prefix.

message-indentation-spaces
     Number of spaces to indent yanked messages.

message-cite-function
     Function for citing an original message.  The default is message-cite-original, which simply inserts the original message and prepends >  to each line. message-cite-original-without-signature does the same, but elides the signature.  You can also set it to sc-cite-original to use Supercite.

message-indent-citation-function
     Function for modifying a citation just inserted in the mail buffer. This can also be a list of functions.  Each function can find the citation between (point) and (mark t).  And each function should leave point and mark around the citation text as modified.

message-mark-insert-begin
     String to mark the beginning of some inserted text.

message-mark-insert-end
     String to mark the end of some inserted text.

message-signature
     String to be inserted at the end of the message buffer.  If t (which is the default), the message-signature-file file will be inserted instead.  If a function, the result from the function will be used instead.  If a form, the result from the form will be used instead. If this variable is nil, no signature will be inserted at all.

message-signature-file
     File containing the signature to be inserted at the end of the buffer. The default is ~/.signature.

message-signature-insert-empty-line
     If t (the default value) an empty line is inserted before the signature separator.

Note that RFC1036bis says that a signature should be preceded by the three characters --  on a line by themselves.  This is to make it easier for the recipient to automatically recognize and process the signature.  So don't remove those characters, even though you might feel that they ruin your beautiful design, like, totally.

Also note that no signature should be more than four lines long. Including ASCII graphics is an efficient way to get everybody to believe that you are silly and have nothing important to say.

Various Message Variables
=========================

message-default-charset
     Symbol naming a MIME charset.  Non-ASCII characters in messages are assumed to be encoded using this charset. The default is nil, which means ask the user.  (This variable is used only on non-MULE Emacsen.  See Charset Translation (Emacs MIME Manual), for details on the MULE-to-MIME translation process.

message-signature-separator
     Regexp matching the signature separator.  It is ^-- *$ by default.

mail-header-separator
     String used to separate the headers from the body.  It is --text follows this line-- by default.

message-directory
     Directory used by many mailey things.  The default is ~/Mail/. All other mail file variables are derived from message-directory.

message-auto-save-directory
     Directory where Message auto-saves buffers if Gnus isn't running.  If nil, Message won't auto-save.  The default is ~/Mail/drafts/.

message-signature-setup-hook
     Hook run when initializing the message buffer.  It is run after the headers have been inserted but before the signature has been inserted.

message-setup-hook
     Hook run as the last thing when the message buffer has been initialized, but before yanked text is inserted.

message-header-setup-hook
     Hook called narrowed to the headers after initializing the headers.

     For instance, if you're running Gnus and wish to insert a Mail-Copies-To header in all your news articles and all messages you send to mailing lists, you could do something like the following:

          (defun my-message-header-setup-hook ()
            (let ((group (or gnus-newsgroup-name "")))
              (when (or (message-fetch-field "newsgroups")
                        (gnus-group-find-parameter group 'to-address)
                        (gnus-group-find-parameter group 'to-list))
                (insert "Mail-Copies-To: never\n"))))

          (add-hook 'message-header-setup-hook
                    'my-message-header-setup-hook)

message-send-hook
     Hook run before sending messages.

     If you want to add certain headers before sending, you can use the message-add-header function in this hook.  For instance:

          (add-hook 'message-send-hook 'my-message-add-content)
          (defun my-message-add-content ()
            (message-add-header "X-In-No-Sense: Nonsense")
            (message-add-header "X-Whatever: no"))

     This function won't add the header if the header is already present.

message-send-mail-hook
     Hook run before sending mail messages.  This hook is run very late -- just before the message is actually sent as mail.

message-send-news-hook
     Hook run before sending news messages.  This hook is run very late -- just before the message is actually sent as news.

message-sent-hook
     Hook run after sending messages.

message-cancel-hook
     Hook run when canceling news articles.

message-mode-syntax-table
     Syntax table used in message mode buffers.

message-cite-articles-with-x-no-archive
     If non-nil, don't strip quoted text from articles that have X-No-Archive set.  Even if this variable isn't set, you can undo the stripping by hitting the undo keystroke.

message-strip-special-text-properties
     Emacs has a number of special text properties which can break message composing in various ways.  If this option is set, message will strip these properties from the message composition buffer.  However, some packages requires these properties to be present in order to work.  If you use one of these packages, turn this option off, and hope the message composition doesn't break too bad.

message-send-method-alist

     Alist of ways to send outgoing messages.  Each element has the form

          (TYPE PREDICATE FUNCTION)

     type
          A symbol that names the method.

     predicate
          A function called without any parameters to determine whether the message is a message of type TYPE.

     function
          A function to be called if PREDICATE returns non-nil. FUNCTION is called with one parameter---the prefix.

          ((news message-news-p message-send-via-news)
           (mail message-mail-p message-send-via-mail))

Sending Variables
=================

message-fcc-handler-function
     A function called to save outgoing articles.  This function will be called with the name of the file to store the article in.  The default function is message-output which saves in Unix mailbox format.

message-courtesy-message
     When sending combined messages, this string is inserted at the start of the mailed copy.  If the string contains the format spec %s, the newsgroups the article has been posted to will be inserted there.  If this variable is nil, no such courtesy message will be added. The default value is "The following message is a courtesy copy of an article\\nthat has been posted to %s as well.\\n\\n".

message-fcc-externalize-attachments
     If nil, attach files as normal parts in Fcc copies; if it is non-nil, attach local files as external parts.

message-interactive
     If non-nil wait for and display errors when sending a message; if nil let the mailer mail back a message to report errors.

Message Buffers
===============

Message will generate new buffers with unique buffer names when you request a message buffer.  When you send the message, the buffer isn't normally killed off.  Its name is changed and a certain number of old message buffers are kept alive.

message-generate-new-buffers
     If non-nil, generate new buffers.  The default is t.  If this is a function, call that function with three parameters: The type, the to address and the group name.  (Any of these may be nil.) The function should return the new buffer name.

message-max-buffers
     This variable says how many old message buffers to keep.  If there are more message buffers than this, the oldest buffer will be killed.  The default is 10.  If this variable is nil, no old message buffers will ever be killed.

message-send-rename-function
     After sending a message, the buffer is renamed from, for instance, *reply to Lars* to *sent reply to Lars*.  If you don't like this, set this variable to a function that renames the buffer in a manner you like.  If you don't want to rename the buffer at all, you can say:

          (setq message-send-rename-function 'ignore)

message-kill-buffer-on-exit
     If non-nil, kill the buffer immediately on exit.

Message Actions
===============

When Message is being used from a news/mail reader, the reader is likely to want to perform some task after the message has been sent.  Perhaps return to the previous window configuration or mark an article as replied.

The user may exit from the message buffer in various ways.  The most common is C-c C-c, which sends the message and exits.  Other possibilities are C-c C-s which just sends the message, C-c C-d which postpones the message editing and buries the message buffer, and C-c C-k which kills the message buffer.  Each of these actions have lists associated with them that contains actions to be executed: message-send-actions, message-exit-actions, message-postpone-actions, and message-kill-actions.

Message provides a function to interface with these lists: message-add-action.  The first parameter is the action to be added, and the rest of the arguments are which lists to add this action to.  Here's an example from Gnus:

       (message-add-action
        `(set-window-configuration ,(current-window-configuration))
        'exit 'postpone 'kill)

This restores the Gnus window configuration when the message buffer is killed, postponed or exited.

An action can be either: a normal function, or a list where the CAR is a function and the CDR is the list of arguments, or a form to be evaled.

Compatibility
*************

Message uses virtually only its own variables---older mail- variables aren't consulted.  To force Message to take those variables into account, you can put the following in your .emacs file:

     (require 'messcompat)

This will initialize many Message variables from the values in the corresponding mail variables.

Appendices
**********

Responses
=========

To determine where a message is to go, the following algorithm is used by default.

reply
     A reply is when you want to respond just to the person who sent the message via mail.  There will only be one recipient.  To determine who the recipient will be, the following headers are consulted, in turn:

     Reply-To

     From

wide reply
     A wide reply is a mail response that includes all entities mentioned in the message you are responded to.  All mailboxes from the following headers will be concatenated to form the outgoing To/Cc headers:

     From
          (unless there's a Reply-To, in which case that is used instead).

     Cc

     To

     If a Mail-Copies-To header is present, it will also be included in the list of mailboxes.  If this header is never, that means that the From (or Reply-To) mailbox will be suppressed.

followup
     A followup is a response sent via news.  The following headers (listed in order of precedence) determine where the response is to be sent:

     Followup-To

     Newsgroups

     If a Mail-Copies-To header is present, it will be used as the basis of the new Cc header, except if this header is never.