[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Composing Messages

All commands for posting and mailing will put you in a message buffer where you can edit the article all you like, before you send the article by pressing C-c C-c. See section `Overview' in Message Manual. Where the message will be posted/mailed to depends on your setup (see section 5.2 Posting Server).

5.1 Mail  Mailing and replying.
5.2 Posting Server  What server should you post and mail via?
5.3 POP before SMTP  You cannot send a mail unless you read a mail.
5.4 Mail and Post  Mailing and posting at the same time.
5.5 Archived Messages  Where Gnus stores the messages you've sent.
5.6 Posting Styles  An easier way to specify who you are.
5.7 Drafts  Postponing messages and rejected messages.
5.8 Rejected Articles  What happens if the server doesn't like your article?
5.9 Signing and encrypting  How to compose secure messages.

Also see section 3.5.4 Canceling Articles for information on how to remove articles you shouldn't have posted.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Mail

Variables for customizing outgoing mail:

List of regexps to match headers included in digested messages. The headers will be included in the sequence they are matched. If nil include all headers.

If non-nil, add a to-list group parameter to mail groups that have none when you do a a.

If non-nil, Gnus will ask you for a confirmation when you are about to reply to news articles by mail. If it is nil, nothing interferes in what you want to do. This can also be a function receiving the group name as the only parameter which should return non-nil if a confirmation is needed, or a regular expression matching group names, where confirmation should be asked for.

If you find yourself never wanting to reply to mail, but occasionally press R anyway, this variable might be for you.

If non-nil, Gnus also requests confirmation according to gnus-confirm-mail-reply-to-news when replying to mail. This is useful for treating mailing lists like newsgroups.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 Posting Server

When you press those magical C-c C-c keys to ship off your latest (extremely intelligent, of course) article, where does it go?

Thank you for asking. I hate you.

It can be quite complicated.

When posting news, Message usually invokes message-send-news (see section `News Variables' in Message Manual). Normally, Gnus will post using the same select method as you're reading from (which might be convenient if you're reading lots of groups from different private servers). However. If the server you're reading from doesn't allow posting, just reading, you probably want to use some other server to post your (extremely intelligent and fabulously interesting) articles. You can then set the gnus-post-method to some other method:

(setq gnus-post-method '(nnspool ""))

Now, if you've done this, and then this server rejects your article, or this server is down, what do you do then? To override this variable you can use a non-zero prefix to the C-c C-c command to force using the "current" server, to get back the default behavior, for posting.

If you give a zero prefix (i.e., C-u 0 C-c C-c) to that command, Gnus will prompt you for what method to use for posting.

You can also set gnus-post-method to a list of select methods. If that's the case, Gnus will always prompt you for what method to use for posting.

Finally, if you want to always post using the native select method, you can set this variable to native.

When sending mail, Message invokes message-send-mail-function. The default function, message-send-mail-with-sendmail, pipes your article to the sendmail binary for further queuing and sending. When your local system is not configured for sending mail using sendmail, and you have access to a remote SMTP server, you can set message-send-mail-function to smtpmail-send-it and make sure to setup the smtpmail package correctly. An example:

(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-default-smtp-server "YOUR SMTP HOST")

To the thing similar to this, there is message-smtpmail-send-it. It is useful if your ISP requires the POP-before-SMTP authentication. See section 5.3 POP before SMTP.

Other possible choices for message-send-mail-function includes message-send-mail-with-mh, message-send-mail-with-qmail, and feedmail-send-it.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 POP before SMTP

Does your ISP require the POP-before-SMTP authentication? It is whether you need to connect to the POP mail server within a certain time before sending mails. If so, there is a convenient way. To do that, put the following lines in your `~/.gnus.el' file:

(setq message-send-mail-function 'message-smtpmail-send-it)
(add-hook 'message-send-mail-hook 'mail-source-touch-pop)

It means to let Gnus connect to the POP mail server in advance whenever you send a mail. The mail-source-touch-pop function does only a POP authentication according to the value of mail-sources without fetching mails, just before sending a mail. Note that you have to use message-smtpmail-send-it which runs message-send-mail-hook rather than smtpmail-send-it and set the value of mail-sources for a POP connection correctly. See section 6.3.4 Mail Sources.

If you have two or more POP mail servers set in mail-sources, you may want to specify one of them to mail-source-primary-source as the POP mail server to be used for the POP-before-SMTP authentication. If it is your primary POP mail server (i.e., you are fetching mails mainly from that server), you can set it permanently as follows:

(setq mail-source-primary-source
      '(pop :server "pop3.mail.server"
            :password "secret"))

Otherwise, bind it dynamically only when performing the POP-before-SMTP authentication as follows:

(add-hook 'message-send-mail-hook
          (lambda ()
            (let ((mail-source-primary-source
                   '(pop :server "pop3.mail.server"
                         :password "secret")))

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Mail and Post

Here's a list of variables relevant to both mailing and posting:


If your news server offers groups that are really mailing lists gatewayed to the NNTP server, you can read those groups without problems, but you can't post/followup to them without some difficulty. One solution is to add a to-address to the group parameters (see section 2.10 Group Parameters). An easier thing to do is set the gnus-mailing-list-groups to a regexp that matches the groups that really are mailing lists. Then, at least, followups to the mailing lists will work most of the time. Posting to these groups (a) is still a pain, though.


This variable controls which information should be exposed in the User-Agent header. It can be one of the symbols gnus (show only Gnus version), emacs-gnus (show only Emacs and Gnus versions), emacs-gnus-config (same as emacs-gnus plus system configuration), emacs-gnus-type (same as emacs-gnus plus system type) or a custom string. If you set it to a string, be sure to use a valid format, see RFC 2616.

You may want to do spell-checking on messages that you send out. Or, if you don't want to spell-check by hand, you could add automatic spell-checking via the ispell package:

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

If you want to change the ispell dictionary based on what group you're in, you could say something like the following:

(add-hook 'gnus-select-group-hook
          (lambda ()
               "^de\\." (gnus-group-real-name gnus-newsgroup-name))
              (ispell-change-dictionary "deutsch"))
              (ispell-change-dictionary "english")))))

Modify to suit your needs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 Archived Messages

Gnus provides a few different methods for storing the mail and news you send. The default method is to use the archive virtual server to store the messages. If you want to disable this completely, the gnus-message-archive-group variable should be nil, which is the default.

For archiving interesting messages in a group you read, see the B c (gnus-summary-copy-article) command (see section 3.25 Mail Group Commands).

gnus-message-archive-method says what virtual server Gnus is to use to store sent messages. The default is:

(nnfolder "archive"
          (nnfolder-directory   "~/Mail/archive")
          (nnfolder-active-file "~/Mail/archive/active")
          (nnfolder-get-new-mail nil)
          (nnfolder-inhibit-expiry t))

You can, however, use any mail select method (nnml, nnmbox, etc.). nnfolder is a quite likable select method for doing this sort of thing, though. If you don't like the default directory chosen, you could say something like:

(setq gnus-message-archive-method
      '(nnfolder "archive"
                 (nnfolder-inhibit-expiry t)
                 (nnfolder-active-file "~/News/sent-mail/active")
                 (nnfolder-directory "~/News/sent-mail/")))

Gnus will insert Gcc headers in all outgoing messages that point to one or more group(s) on that server. Which group to use is determined by the gnus-message-archive-group variable.

This variable can be used to do the following:

a string
Messages will be saved in that group.

Note that you can include a select method in the group name, then the message will not be stored in the select method given by gnus-message-archive-method, but in the select method specified by the group name, instead. Suppose gnus-message-archive-method has the default value shown above. Then setting gnus-message-archive-group to "foo" means that outgoing messages are stored in `nnfolder+archive:foo', but if you use the value "nnml:foo", then outgoing messages will be stored in `nnml:foo'.

a list of strings
Messages will be saved in all those groups.

an alist of regexps, functions and forms
When a key "matches", the result is used.

No message archiving will take place. This is the default.

Let's illustrate:

Just saving to a single group called `MisK':

(setq gnus-message-archive-group "MisK")

Saving to two groups, `MisK' and `safe':

(setq gnus-message-archive-group '("MisK" "safe"))

Save to different groups based on what group you are in:

(setq gnus-message-archive-group
      '(("^alt" "sent-to-alt")
        ("mail" "sent-to-mail")
        (".*" "sent-to-misc")))

More complex stuff:

(setq gnus-message-archive-group
      '((if (message-news-p)

How about storing all news messages in one file, but storing all mail messages in one file per month:

(setq gnus-message-archive-group
      '((if (message-news-p)
          (concat "mail." (format-time-string "%Y-%m")))))

Now, when you send a message off, it will be stored in the appropriate group. (If you want to disable storing for just one particular message, you can just remove the Gcc header that has been inserted.) The archive group will appear in the group buffer the next time you start Gnus, or the next time you press F in the group buffer. You can enter it and read the articles in it just like you'd read any other group. If the group gets really big and annoying, you can simply rename if (using G r in the group buffer) to something nice---`misc-mail-september-1995', or whatever. New messages will continue to be stored in the old (now empty) group.

That's the default method of archiving sent messages. Gnus offers a different way for the people who don't like the default method. In that case you should set gnus-message-archive-group to nil; this will disable archiving.

All outgoing messages will be put in this group. If you want to store all your outgoing mail and articles in the group `nnml:archive', you set this variable to that value. This variable can also be a list of group names.

If you want to have greater control over what group to put each message in, you can set this variable to a function that checks the current newsgroup name and then returns a suitable group name (or list of names).

This variable can be used instead of gnus-message-archive-group, but the latter is the preferred method.

If non-nil, automatically mark Gcc articles as read.

If nil, attach files as normal parts in Gcc copies; if a regexp and matches the Gcc group name, attach files as external parts; if it is all, attach local files as external parts; if it is other non-nil, the behavior is the same as all, but it may be changed in the future.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6 Posting Styles

All them variables, they make my head swim.

So what if you want a different Organization and signature based on what groups you post to? And you post both from your home machine and your work machine, and you want different From lines, and so on?

One way to do stuff like that is to write clever hooks that change the variables you need to have changed. That's a bit boring, so somebody came up with the bright idea of letting the user specify these things in a handy alist. Here's an example of a gnus-posting-styles variable:

  (signature "Peace and happiness")
  (organization "What me?"))
  (signature "Death to everybody"))
  (organization "Emacs is it")))

As you might surmise from this example, this alist consists of several styles. Each style will be applicable if the first element "matches", in some form or other. The entire alist will be iterated over, from the beginning towards the end, and each match will be applied, which means that attributes in later styles that match override the same attributes in earlier matching styles. So `comp.programming.literate' will have the `Death to everybody' signature and the `What me?' Organization header.

The first element in each style is called the match. If it's a string, then Gnus will try to regexp match it against the group name. If it is the form (header match regexp), then Gnus will look in the original article for a header whose name is match and compare that regexp. match and regexp are strings. (The original article is the one you are replying or following up to. If you are not composing a reply or a followup, then there is nothing to match against.) If the match is a function symbol, that function will be called with no arguments. If it's a variable symbol, then the variable will be referenced. If it's a list, then that list will be evaled. In any case, if this returns a non-nil value, then the style is said to match.

Each style may contain an arbitrary amount of attributes. Each attribute consists of a (name value) pair. In addition, you can also use the (name :file value) form or the (name :value value) form. Where :file signifies value represents a file name and its contents should be used as the attribute value, :value signifies value does not represent a file name explicitly. The attribute name can be one of:

The attribute name can also be a string or a symbol. In that case, this will be used as a header name, and the value will be inserted in the headers of the article; if the value is nil, the header name will be removed. If the attribute name is eval, the form is evaluated, and the result is thrown away.

The attribute value can be a string (used verbatim), a function with zero arguments (the return value will be used), a variable (its value will be used) or a list (it will be evaled and the return value will be used). The functions and sexps are called/evaled in the message buffer that is being set up. The headers of the current article are available through the message-reply-headers variable, which is a vector of the following headers: number subject from date id references chars lines xref extra.

If you wish to check whether the message you are about to compose is meant to be a news article or a mail message, you can check the values of the message-news-p and message-mail-p functions.

So here's a new example:

(setq gnus-posting-styles
         (signature-file "~/.signature")
         (name "User Name")
         (x-face-file "~/.xface")
         (x-url (getenv "WWW_HOME"))
         (organization "People's Front Against MWM"))
         (signature my-funny-signature-randomizer))
        ((equal (system-name) "gnarly")  ;; A form
         (signature my-quote-randomizer))
        (message-news-p        ;; A function symbol
         (signature my-news-signature))
        (window-system         ;; A value symbol
         ("X-Window-System" (format "%s" window-system)))
        ;; If I'm replying to Larsi, set the Organization header.
        ((header "from" "larsi.*org")
         (Organization "Somewhere, Inc."))
        ((posting-from-work-p) ;; A user defined function
         (signature-file "~/.work-signature")
         (address "user@bar.foo")
         (body "You are fired.\n\nSincerely, your boss.")
         (organization "Important Work, Inc"))
         (From (save-excursion
                 (set-buffer gnus-article-buffer)
                 (message-fetch-field "to"))))
         (signature-file "~/.mail-signature"))))

The `nnml:.*' rule means that you use the To address as the From address in all your outgoing replies, which might be handy if you fill many roles.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7 Drafts

If you are writing a message (mail or news) and suddenly remember that you have a steak in the oven (or some pesto in the food processor, you craaazy vegetarians), you'll probably wish there was a method to save the message you are writing so that you can continue editing it some other day, and send it when you feel its finished.

Well, don't worry about it. Whenever you start composing a message of some sort using the Gnus mail and post commands, the buffer you get will automatically associate to an article in a special draft group. If you save the buffer the normal way (C-x C-s, for instance), the article will be saved there. (Auto-save files also go to the draft group.)

The draft group is a special group (which is implemented as an nndraft group, if you absolutely have to know) called `nndraft:drafts'. The variable nndraft-directory says where nndraft is to store its files. What makes this group special is that you can't tick any articles in it or mark any articles as read--all articles in the group are permanently unread.

If the group doesn't exist, it will be created and you'll be subscribed to it. The only way to make it disappear from the Group buffer is to unsubscribe it. The special properties of the draft group comes from a group property (see section 2.10 Group Parameters), and if lost the group behaves like any other group. This means the commands below will not be available. To restore the special properties of the group, the simplest way is to kill the group, using C-k, and restart Gnus. The group is automatically created again with the correct parameters. The content of the group is not lost.

When you want to continue editing the article, you simply enter the draft group and push D e (gnus-draft-edit-message) to do that. You will be placed in a buffer where you left off.

Rejected articles will also be put in this draft group (see section 5.8 Rejected Articles).

If you have lots of rejected messages you want to post (or mail) without doing further editing, you can use the D s command (gnus-draft-send-message). This command understands the process/prefix convention (see section 8.1 Process/Prefix). The D S command (gnus-draft-send-all-messages) will ship off all messages in the buffer.

If you have some messages that you wish not to send, you can use the D t (gnus-draft-toggle-sending) command to mark the message as unsendable. This is a toggling command.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8 Rejected Articles

Sometimes a news server will reject an article. Perhaps the server doesn't like your face. Perhaps it just feels miserable. Perhaps there be demons. Perhaps you have included too much cited text. Perhaps the disk is full. Perhaps the server is down.

These situations are, of course, totally beyond the control of Gnus. (Gnus, of course, loves the way you look, always feels great, has angels fluttering around inside of it, doesn't care about how much cited text you include, never runs full and never goes down.) So Gnus saves these articles until some later time when the server feels better.

The rejected articles will automatically be put in a special draft group (see section 5.7 Drafts). When the server comes back up again, you'd then typically enter that group and send all the articles off.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9 Signing and encrypting

Gnus can digitally sign and encrypt your messages, using vanilla PGP format or PGP/MIME or S/MIME. For decoding such messages, see the mm-verify-option and mm-decrypt-option options (see section 3.30 Security).

Often, you would like to sign replies to people who send you signed messages. Even more often, you might want to encrypt messages which are in reply to encrypted messages. Gnus offers gnus-message-replysign to enable the former, and gnus-message-replyencrypt for the latter. In addition, setting gnus-message-replysignencrypted (on by default) will sign automatically encrypted messages.

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.

See section `Security' in Message Manual, for more information.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs Webmaster on October, 2 2007 using texi2html