# Mutt and the Single User

## scottro

mutt and the Single User

The Gentoo.org's Desktop

Guide gives a quick start guide to using mutt.  However, it

talks about using mutt in conjunction with postfix.

I add to this as I learn new things about mutt, so if you find it useful, you might want to check back on it from time to time.

 Please note: The original version of this document instructed the user to create lockfiles. This may cause seg faults when transferring between mailboxes.  The correction was made on May 27, 2002

Note number 2.  In mid January of 2003 I decided to change the article so that getmail rather than fetchmail is used.  So, the references to fetchmail in the posts below this one refer to the older version of the article.

 Note number 3

As the main docs at Gentoo org now feature an article on mutt with procmail and nbsmtp I no longer maintain this article.  I have a page on mutt that I do keep a bit more up to date at

http://home.nyc.rr.com/computertaijutsu/mutt.html

 Note number 4

Getmail is now up to version 4 and the syntax has changed.  Again, see my 

computertaijutsu mutt page for information on its configuration.  Basically instead of what is below it would be

[retriever]

type = SimplePOP3Retriever

server = popserver.isp.com

username = john

password = 1234

[options]

verbose = 0

delete = true

[destination]

type = MDA_external

path = /usr/bin/procmail

unixfrom = true

I'll leave the older getmail config information up for awhile, but the above is how it should now be configured.  

For the single user, this can be a bit of overkill. If you're just

using one email account on a workstation, you can take advantage of

mutt's simplicity to run it without having postfix or sendmail

constantly running in the background.  Additionally, mutt is capable

of a few tricks not mentioned in the Desktop Guide.

I have  a

page on mutt that might also be of use.  However, that one

covers its usage under a few distros as well as FreeBSD, so this one

will be Gentoo specific.

Firstly, let's install mutt

```
emerge mutt
```

For purposes of

this article, we'll assume that we are user john with an email

address of john@isp.com.  User john's password with his isp is 1234,

his ISP uses a pop server called popserver.isp.com and an smtp

server called smtpserver.isp.com.  The only accounts on the box are

root and john.

Before getting started, we'll need three more programs, procmail,

getmail and nbsmtp. So, let's install them.

```
 emerge procmail getmail nbsmtp
```

One thing that keeps changing, and that I will probably not keep up to date is that one of these programs may emerge ssmtp as a dependency.  That will block the emerge of nbsmtp. At present, (July 2002) it's procmail that does it. So, before emerging nbsmtp, you might have to unmerge ssmtp.

```

emerge -C ssmtp

```

The emerge of course, will be done as root (or using sudo).  Once that's finished,

however, go back to being user john.  Most of the rest of this will be done

by john, as john in his home directory. So, if you're not in the

home directory, get there.  If you logged in as user john and did an

su to root, then simply type

```
exit
```

Then you will once again be john. If you logged in as root, then su

to john.

```
su - john
```

Now, to get to john's home directory

```
cd
```

So, we now have mutt, ssmtp, nbsmtp,  getmail and procmail installed.  The

first step is to make it possible for john to get his email.  For

this, we'll use getmaill.

We have to set up a .getmail/getmailrc in the home directory  (note the period in front of

the name). 

In /usr/share/doc/getmail<version>  there is a gzipped getmailrc-example file. So, we copy it into our .getmail directory and gunzip it.

```

cd

mkdir .getmail

cp /usr/share/doc/getmail-2.3.8/getmailrc-example.gz ~/.getmail

cd .getmail

gunzip getmailrc-example

```

(At time of writing the version is 2.3.8--this should be changed to the version number that

you have)

Open the file with your favorite text editor. 

 I use vi--if you're using nano then don't forget the -w

option, so that you don't run into problems with wordwrap.

I usually leave the first section, [default] alone.  The second section [Joe's Mail] is

the one that we're going to edit. Right now it looks like

```

[Joe's Mail]                                    # Simple configuration for a single-user POP3 mailbox

server = mail.isp.com

port = 8110

username = joeuser

                                                # no password specified; prompt for it when getmail is run

use_apop = 1                                    # Use APOP authentication for this account instead of

                                                #   cleartext PASS

postmaster = ~joeuser/Mail/default/             # Default delivery to this Maildir

message_log = ""                                # Don't log for this account

                                                # No "local" directives necessary.

recipient_header = received                     # For this account, only look for recipient headers

recipient_header = x-envelope-to                #   in "Received:" and "X-Envelope-To:" headers

no_delivered_to = 1                             # Don't add a Delivered-To: header for this mailbox

no_received = 1                                 # Don't add a Received: header for this mailbox

```

With user john who has the account john@isp.com, a password of 1234 and a pop server called pop.isp.com, we'll change it so that it reads

```

[John's Mail]                                    # Simple configuration for a single-user POP3 mailbox

server = pop.isp.com

port = 110

username = john

password = 1234

                                                # no password specified; prompt for it when getmail is run

use_apop = 0                                   # Use APOP authentication for this account instead of

                                                #   cleartext PASS

postmaster = "|/usr/bin/procmail"             # Default delivery to this Maildir

message_log = ""                                # Don't log for this account

                                                # No "local" directives necessary.

recipient_header = received                     # For this account, only look for recipient headers

recipient_header = x-envelope-to                #   in "Received:" and "X-Envelope-To:" headers

no_delivered_to = 1                             # Don't add a Delivered-To: header for this mailbox

no_received = 1                                 # Don't add a Received: header for this mailbox

```

Some of this is obvious, some not.  A numerical value of 0 means false--unless your isp uses APOP authentication, set that value to false. We're not logging. (If you do log, then the easiest way to do it is to put the log in the user's home directory so you don't run into permissions problems.  We're handing the mail off to procmail to be delivered to user john's

mailbox or mailboxes.

The part of the file that follows can be deleted, or commented out.

Now, to avoid an annoying error message, we set permissions at 0710.

```
chmod 0710 .getmail/getmailrc
```

You can call getmail by simply typing its name at the command line

and watch it work.  You might, until you're sure that it's working properly, call it with the -v or -v -v option (for verbose) to make sure all is working correctly.  

Unlike fetchmail, getmail doesn't have a -d for daemon option. The author suggests running it as a cronjob, which is probably the easiest way to do it. (Other folks write while loop scripts, but I'm fairly lazy).

This next part will have to be done either as root or with root privileges.  If you haven't installed any cron program then install one now--we'll use vcron as it's suggested in the install documents.

```

emerge vcron

```

Now, as root or with root privilege, we'll create a crontab file for user john

```

crontab -eu john

```

The e is for edit and u for user.  

For those not familiar with crontab, there are 6 fields---minute hour day week month and the command to be run.  If you don't want to specify a particular field, you can use an asterisk.  So, we're going to set getmail to run every ten minutes.

(I'm leaving the below iin because it might make it a bit clearer about how crontab works, but see a couple of paragraphs down for cleaner and easier syntax)

After the previous command, your default text editor should have opened. If you're using nano, be careful of the wordwrap.  So, since we're only worried about minutes, we're going to simply indicate the other fields with asterisks. In the text editor type

```

10,20,30,40,50,00 * * * * /usr/bin/getmail

```

(A quick note--when I first put in the getmail section, I mistyped the above as **** with no spaces in between the asterisks--as you'll note if you bother to read some of the comments on this, that will, of course, cause an error)

If you read the responses to this article, you'll see a cleaner way to do the crontab.  Rather 

than the version above, one can just do

```

*/10 * * * * /usr/bin/getmail

```

Now, getmail will run every ten minutes.  If for some reason you want to remove this cronjob, then the command is

```

crontab -ru john

```

The r is for remove.  Lastly, one can list the cronjob with an l option. (A lower case letter L).

```

crontab -lu john

```

One little trick--if, for whatever reason, you sometimes get mail on this box and sometimes on another so are constantly adding and removing the cronjob you can simply save it as a file.

For example

```

crontab -lu john > crontab.txt

```

Then, when you restart the cron job you can simply copy that text back in. For instance, I use vi, so suppose I've removed the cronjob. Now, I want to put it back.  If I type

```

cronjob -eu john

```

vi opens up. Then, I can simply type, while in command mode

```

:r ~/crontab.txt

```

and the job is back in place. 

Before leaving getmail, one more point. If your MDA writes to stderr then the session will fail.

For example, I have a despammed.com address.  I like despammed.com but they insert a [despammed] tag into each email, which can be an annoyance, especially when on mailing lists.  Therefore, my first procmail rule is

```

* ^Subject.*\[despammed\]

| sed -e '/^Subject:.*\[despammed\]/s/\[despammed\] //g'

```

(We'll cover procmail filtering later in this article--if any NYLUGers read this, George, who is far better at sed than I am, gave me the rule.)

The trouble is that if an email comes to any of my other addresses, procmail will write "skipped subject despammed" to stderr  (for newcomers who are unfamiliar with these terms, that's standard error.)  Then the delivery will fail and I won't get that mail.  

The solution is detailed on [url=http.www.qcc.sk.ca/~charlesc/software/getmail-2.0/]getmail's site.[/url]  If you know that your MDA can successfully continue even if something goes to

stderr, as in the above example (after skipping the despammed part, procmail continues to deliver mail to my various mailboxes without problem) change the postmaster line to read

```

postmaster ="|/usr/bin/procmail 2>&1"

```

You can leave mutt open and check it every few minutes, or use a program like 

 xbuffy to keep track of messages. (Xbuffy, as it's name implies, only works while in X).

.  If you don't want to run getmail as a cronjob, you can do something like

```

getmail &&

mutt

```

You can also do a key binding so that you can simply invoke getmail when you feel like it, similar to clicking a send receive button in a graphical emailer. This will be covered below, in the section on w3m.

We want to configure mutt. At this point, we're just configuring it

enough to read and send our email.  So, open up your text editor

(again, if you use nano, be sure to remember the -w option--this is

the last time I'll mention it)

```
vi .muttrc
```

Although a more typical .muttrc would use Mail for the first line,

Gentoo uses the ~/.maildir format.  So, our .muttrc will be set as

follows

```

set folder=~/.maildir

set sendmail="/usr/bin/nbsmtp -d isp.com -f john@isp.com -h

smtpserver.isp.com"

my_hdr From: John <john@isp.com>

```

The first line tells mutt where it's putting the mail. The second

line is telling it what to use to send mail, in this case, nbsmtp

which I will explain more fully in a moment.  Lastly, the my_hdr

line is what will appear in john's header.

Gentoo actually gives a system wide Muttrc in /etc/mutt.  If you're running postfix or the like, that would possibly be sufficient, however, you will want to customize your headers, at least.  Also, you're far better off making an error in the user's home directory than in the system wide one, so, I usually ignore the /etc/mutt/Muttrc and create my own.

Despite its power, mutt is a small and lightweight mail client.

Whereas pine will provide its own smtp for sending mail, mutt will

usually rely upon postfix or sendmail.  We don't need either one,

however. All we need is a small smtp client--in this case, nbsmtp,

which stands for no-brainer smtp.

The /usr/bin/nbsmtp is obviously the path to it.  The -d is for

domain--if john's email is john@isp.com then the domain is isp.com.

The -f is the from tag--it's from john@isp.com and the -h is for

host--isp com's smtp server is smtpserver.isp.com.

On one or two Gentoo installs, nbsmtp didn't work properly. Lazy

sort that I am, I decided that since ssmtp is included, I might as

well use it.  So, if, when trying to send mail, nbsmtp doesn't seem

to work for some reason, and there's no mistake that you can see in

your configuration, then try ssmtp.  It was installed when you

installed mutt.  (However, it might have had to be uninstalled when you put in nbsmtp, so you might have reinstall it)

The ssmtp program has two other advantages over the simpler nbsmtp.  It writes to /var/log/maillog and can send mail to a maximum of 100 users at a time. (nbsmtp seems to have a limit of about 4 or 5)

So, once again, open up your .muttrc file and

change the sendmail line to read

```
set sendmail="/usr/bin/ssmtp"
```

The ssmtp program is little more involved to set up, but it's

actually quite simple.  You'll find that you have a file in /etc

that can be found at /etc/ssmtp/ssmtp.conf  (There may only be one

called ssmtp.conf.sample or something similar, in that case simply

copy it over as ssmtp.conf

```

cd /etc/ssmtp

cp ssmtp.conf.sample ssmtp.conf

```

Now we'll edit ssmtp.conf

When you open the file in your favorite text editor, you'll see that

it begins

```

#

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.

#

# The person who gets all mail for userids < 1000

root=postmaster

# The place where the mail goes. The actual machine name is required

# no MX records are consulted. Commonly mailhosts are named

# mail.domain.com

# The example will fit if you are in domain.com and your mailhub is

# so named.

mailhub=mail

# Example for SMTP port number 2525

# mailhub=mail.your.domain:2525

# Example for SMTP port number 25 (Standard/RFC)

# mailhub=mail.your.domain

# Where will the mail seem to come from?

rewriteDomain=yourdomain.com

# The full hostname

hostname=mail.yourdomain.com

```

There's usually more to it, but the above contains the only part

that we'll have to edit.

First, the line mailhub=mail will be changed to read

```

mailhub=smtpserver

```

In other words, the first part of smtpserver.isp.com's FQDN (Fully

Qualifed Domain Name.  However, this doesn't always work.  You may need to put in the entire name, that is smtp.server.isp.com)

Next the rewriteDomain=yourdomain.com will be changed to his ISP's

domain name.  So, it will read

```
rewriteDomain=isp.com
```

Lastly, the hostname line.  

This is the hostname of his workstation. So, if he called it johnsbox.isp.com it'd be 

```
hostname=johnsbox.isp.com
```

The ssmtp program is now ready to use, and should send his mail

without problem.

Gentoo uses nano as its default editor. If you would prefer to use

vi to compose messages, then you would add the following to your

.muttrc

```
set editor=vi
```

Mutt will now use vi rather than nano as its editor.  (You can also, as root, edit /etcprofile so that the default editor is vi, rather than nano which will do the same thing)

It's now ready to send and receive mail.  However, there are a few

more things you might want to do. 

When you first open mutt (by simply typing 

```

mutt
```

at a command line, it will say something like .maildir does not exist, create it now? We answer yes. (This is covered in the desktop guide).

On occasion, you will find that mutt complains that .maildir is not a mailbox.  This is easily fixed--the solution was posted recently by Echo5ive at

https://forums.gentoo.org/viewtopic.php?t=7780

Add three directories to your .maildir named cur tmp and new. The next time you start mutt, you won't see the error message.  So, make the directories.

```

cd .maildir

mkdir cur

mkdir tmp

mkdir new

```

This fixes that problem.  

One thing you'll notice is that

mutt shows full mail headers. If you find this more information than

you really want, you can add the following to your .muttrc file

```

ignore *

unignore date from to cc subject resent-from reply-to x-mailer

```

This can be adjusted according to your personal taste--the above

example will only show the headers of the date, the from, the to,

cc, the subject, resent-from if it was forwarded, the reply-to and

the x-mailer.

This may be enough for the average user. However, we're going to

finetune mutt a little more.

Viewing and getting to urls in an email message

Right now, if you receive an email message with a url, you'll have

to cut and paste the url into your browser.  We're going to fix this

now.  Once more, su to root and emerge w3m, a text based browser

that has some similarities to lynx but a few more capabilities.

```
emerge w3m
```

Once this is done switch back to being user john.

Now, we're going to add the following to our .muttrc file

```
macro pager \cb |w3m\n
```

The \cb means that we're binding the Ctrl + b key to start up w3m

while in mutt.  So, if you're reading a message that has a url in

it, and you'd like to simply get to the url, hit Ctrl + B and the

email will open up in w3m.  You'll now see more header information

and such.  You can now get to the url in the same way you would

navigate in vi.  Start by hitting the colon key.  Say the url is http://www.example.com you could get there quickly with

```
/example
```

Your cursor will then be on the example part of the url.  Hitting

the enter key will now open up the url in w3m.

Also, w3m can be used to read those html formatted mails we all love.  You'll find that you have a file, /etc/mailcap.  In it are two lines beginning with

```

text/html; /usr/bin/lynx -dump

```

then it continues, one saying -force etc and the other saying -dump etc.  You can change lynx in these two lines to w3m, but you also need to add a line saying (or modify the -dump line)

```

text/html; /usr/bin/w3m -dump -T text/html %s

```

(This doesn't always work--I've never really investigated it as most of the html mail I get is spam.  On the other hand, if I do emerge lynx and leave

 /etc/mailcap alone I can view those html messages--as I said, most of them turn out to be spam).

Earlier, I said I would cover keybinding getmail in this section. If you don't feel like waiting till the next time getmail is supposed to run, you  simply invoke it  by hitting 

```

G

```

(Note that that is a capital G)  For this to work, however, you have to add a couple of lines to your .muttrc

```

macro index       G "!getmail\n"  "Invoke getmail"

macro pager       G "!getmail\n"  "Invoke getmail"

```

Filtering email with procmail

The next thing we'll cover is filtering mail. If you're on several

mailing lists, then you'd probably like to sort your mail into

various mailboxes.  This is not very hard to do.

The following is taken from the

Procmail

Quickstart Guide.  The Quickstart Guide goes into far greater

detail, however this should get you up and running with mail

filtering.

So, let's create a .procmailrc file

```

PMDIR=$HOME/Procmail

VERBOSE=no

MAILDIR=$HOME/.maildir

INCLUDERC=$PMDIR/rc.lists

```

This tells procmail to look in a directory called Procmail in the

user's home directory.  For filtering, it's going to check a file

called rc.lists in that Procmail directory. So, let's create the

two.

```

mkdir Procmail

cd Procmail

```

Now, using your text editor, open a new file that we'll call

rc.lists

The Quickstart guide recommends putting your busiest lists first.

So, the two busiest lists to which I belong are freebsd-questions

and gentoo-user. Therefore, I start with those.  Note that it is the numeral zero, not a capital letter o.

(A quick note---the quickstart guide has a slightly different syntax--rather than :0 they have :0:   This creates a lockfile, which we don't want.  It may cause seg faults when changing between mailboxes. Gentoo uses the .maildir format so lock files are unnecessary.)

```

:0

* ^TO_freebsd-questions

IN-bsdquestions

:0

* ^TO_gentoo-user

IN-gentoo-user

```

Now, when you run getmail, it will filter any messages addressed

to freebsd-questions@freebsd.org. The ^TO_ means that it will search

for a header beginning with To, Cc, Resent-To or other destination

parameter, followed by any (or no) characters, followed by an email

address beginning with freebsd-questions@freebsd.org. It's

case-insensitive too, which is handy.

You can put as many of these as you like. You don't have to create

the FreeBSD_Questions mailbox, it will be created the first time

you get a message sent to freebsd-questions. Sometimes, people send

to questions@freebsd.org so I add a rule for that one too--I want it

to go in the same mailbox as something addressed to

freebsd-questions@freebsd.org

```

:0

* ^TO_questions@freebsd.org

IN-bsdquestions

```

Once this is done, if the mail you get is filtered into one of these

mailboxes, when you open mutt, you won't see them.  Anything not

covered by your filters will simply go into the default inbox

To view the other mailboxes, simply hit the letter c (no Ctrol or

Alt is necessary)  You'll see a message

```
Open Mailbox ("?" for list)
```

Hitting the ? key (or the tab key, which will also work) shows me a

list of my mailboxes. Although it doesn't show me how many messages

are in each, any empty mailbox will have a 0 in front of it,

indicating that no mail was filtered to that box.  Use the arrow key

to highilght the desired mailbox, then hit enter, and you'll see the

messages in that box.

Another filtering trick that I find useful is this one to strip things in brackets out of a subject line.  For example I use the excellent www.despammed.com to help filter out spam. However, they have the to me inconvenient habit of putting a [despammed] in each subject line.  Therefore, my friend George, a sedmeister, gave me this simple filter for it. It should probably go at the top of your rc.lists

```

:0 f

* ^Subject.*\[despammed\]

| sed -e '/^Subject:.*\[despammed\]/s/\[despammed\] //g'

```

A couple of other tricks that I find useful--to nicely sort my mail that doesn't fit into other categories, I have, at the bottom of my rc.lists a rule for that. Using our john@isp.com as an example, one could put, as the last entry on the list

```

:0

* ^TO_john@isp.com

IN-personal

```

(If he needed it for his john@isp1.com account as well, he'd just add that.  

I'm a little anal, I want everything to go somewhere--so, actually, my last rc.lists rule is

```

:0

* ^TO_.*.

IN-misc

```

You can also filter sent mail.  Gentoo copies sent mail to .maildir-sent by default--this has directories of cur new and temp, but finding a sent message can be a bit of a chore.  So, I copy my sent messages to a folder in my .maildir called SENT, where they are easily viewed. To do this, I add the line to my .muttrc file

```

fcc-hook .*. "~/.maildir/SENT"

```

The .*. captures all sent mail and puts it in the SENT directory.

Some people prefer to divide their sent mail into various folders. This is easily accomplished. Remember, the .muttrc line above will capture all sent mail--so, as .muttrc processes commands in order, if you want to capture some sent messages and put them elsewhere, insert any such lines above the .*. filter. For example

```

fcc-hook "gentoo-user"  "~/.maildir/Gentoo-sent"

```

Speaking of segfaults, which I was doing a few paragraphs ago--some folks find that they will get a segmentation fault if they are emerging something while using mutt.  One possible cause of this is that the ebuild and mutt may be trying to share the /tmp directory.  One, as yet unverified way around this is to give mutt its own tmp directory in your home directory.   So, first create a tmp directory in your home directory.  (If you skip this step, you'll get a message that mutt can't open the temporary files).

```

cd

mkdir tmp

```

Then, open up the .muttrc file and add the line

```

set tmpdir="~/tmp"

```

I repeat, I haven't verified that this will always work. The trouble is that I would only get these segfaults sometimes while emerging and simultaneously using mutt.  Therefore, the fact that I haven't gotten a segfault while doing both at once since then isn't a guarantee that this will fix the problem.

(Note--since this was written, someone on gentoo-user mentioned that it had not fixed the problem--he was still getting segfaults when using mutt while emerging.  However, having a ~/tmp directory certainly won't hurt and helps to keep everything in its place).

(Note. Since writing the above, I've confirmed that not only does it seldom work, but that the problem is related to sandbox, and was reported on bugzilla back in February 2002.  Interested readers can check current status of the bug at

https://bugs.gentoo.org/show_bug.cgi?id=501.

Further update to the above--if one looks at the above url, you'll see that if you're running a later version of 

gcc (2.95.3-r7 or gcc3) and 

glibc 2.2.5-r7 (which was unmasked when I did an emerge rsync on August 19, 2002) fixes the problem.  So, I'm guessing that it will be fixed by the time 1.4 is released)

Aliases--Mutt's Address Book

While mutt doesn't have an Outlook Express type address book, one can keep a list of addresses with an alias file.  Open your .muttrc file and add the lines

```

set alias_file=~/.mutt_aliases

source ~/.mutt_aliases

```

Suppose you want to keep the address for gentoo-user@gentoo.org, gentoo-newbies@gentoo.org and the address for your friend John Smith who has an email address of jsmith@isp.com.  Outlook Express has spoiled you so you only want to type a few letters and have the address complete itself.  You want to able to type genu for gentoo-user, genn for gentoo-newbies and john for your friend John. 

With your text editor, create a new file called .mutt_aliases. In it, enter the following

```

alias genu       <gentoo-user@gentoo.org>

alias genn       <gentoo-newbies@gentoo.org>

alias john         John Smith    <jsmith@isp.com>

```

The next time you open mutt, when you type m to send an email, all you have to do is type in the alias.  You won't see it expand to the proper address until after you've written the email and are ready to send it, but the alias will expand to the proper address. In the case of John, you will see the John Smith in the header as well as his email address.

You can also, once the To: line comes up, simply hit the tab key and you will see your list of aliases at the top of the screen.

If you want to create an alias for the sender of the email that you are currently viewing, simply hit 

```

a

```

Mutt will then open up a dialog to create the alias.  However, at least in Gentoo, I've found that it wants to store it in /.mutt_aliases.  Therefore, you might have to manually edit that line--for instance, I have my .mutt_aliases in my home directory, so I simply eliminate the first /    It will then save it to .mutt_aliases.

Replying to a mailing list

Recently, there have been some changes in the Gentoo lists--they are going to set it so that reply to will only reply to a sender rather than the entire list.  There are arguments for and against this but dealing with it is not difficult.

Open up your .muttrc file and add the line

```

subscribe gentoo-

```

Now, when you have message from one of the Gentoo lists, and want to reply to the list, you can simply hit 

```

L

```

(Note that it's capitalized)

This will send your reply to the list rather than the individual.  The idea of the subscribe line is to give .muttrc enough of an idea of the mailing list for it to find it.  For example, freebsd-questions@freebsd.org has the same format, where a reply will go to the original poster rather than the mailing list.  However, some people, rather than posting to freebsd-questions@freebsd.org just post to questions@freebsd.org.  Therefore, if your .muttrc had 

```

subscribe freebsd-questions

```

and you then hit L to reply to someone who had posted to questions@freebsd.org rather than freebsd-questions@freebsd.org mutt will then complain that no mailing list was found.  

The other way to do this, without altering your .muttrc is to simply hit

```

g

```

for group. It will then reply to the posters and send a cc to the mailing list.  The disadvantage of this method is that the string of recepients grows and grows as people join the thread--and all of them receive two copies of the message which can be a nuisance.

HOWEVER--in many cases, especially on a list as busy as FreeBSD-questions, which doesn't require you to subscribe in order to post, this can actually be an advantage.  Many of the gurus on the list seldom have time to look at each email, and won't respond unless they get a private copy.  Also, on freebsd-questions, one will frequently see something like, "Please respond to me personally as I am not subscribed."  Therefore, the private copy that each participant in a thread receives can actually be a Good Thing (TM)

As adding subscribe lines to .muttrc is not a big deal, I usually add them, to give myself the option. Then, if, for example, I'm replying to one of the FreeBSD gurus, or if the original poster has requested a private reply, I use the g for group option.  If it seems unecessary, I simply use the L option.

As many of the more technical Unix lists use this format it's a handy trick to know

Sending from different email accounts

Sometimes you have more than one email account. There are various ways to do this--however, I'm giving the one that I use, as I find it the easiest. Your mileage may vary.

So, let's return to our user john at isp.com. 

[/code]

The first thing he has to do is add his second account to getmailrc.  So, let's say he now has signed up with a second isp, isp1.com. His email there is john@isp1.com, their pop server is pop.isp1.com, his username is again john and his password is again 1234. The smtp server is smtp.isp1.com.

So, he'll copy over the [John's Mail] section of his getmailrc and just change the server line

to read

```

server = pop.isp1.com

```

Now he goes to his .muttrc file.  The original one looks like

```

set folder=~/.maildir

set sendmail="/usr/bin/nbsmtp -d isp.com -f john@isp.com -h

smtpserver.isp.com"

my_hdr From: John <john@isp.com>

```

However, now he wants to use his john@isp1.com account to send and receive from gentoo-user.  The  current set sendmail line and my_hdr line will be his default. If he wanted to make isp1 his default, he would change those two lines accordingly.  However, in this case, he only wants to use the isp1 address when sending mail to gentoo-user.

So, he will add these lines to his .muttrc file

```

send-hook "gentoo-user@gentoo.org"  "my_hdr john@isp1.com"

send-hook "gentoo-user@gentoo.org"  'set sendmail="/usr/bin/nbsmtp -d isp1.com -f john@isp1.com -h smtp.isp1.com"'

```

Note that the send-hook lines should be on one line each. If half of the set sendmail line is on a second line, mutt will complain about errors in .muttrc.  You may know that you can indicate that something should be read as one line with a \   (If you're not familiar with this, for it to work, don't hit the space bar after hitting enter--in other words, for our set sendmail line, you might do this

```

send-hook "gentoo-user@gentoo.org"   'set sendmail="usr/bin/nbsmtp -d isp1.com \

-f john@isp1.com -h smtp.isp1.com"'

```

You might have to play with the spacing here--if, when you start up mutt again, it gives you an error in .muttrc it probably means that you added an extra white space--in general, I find it works best when, if the unbroken line would have been -d isp1.com -f john@isp1.com then there should be a white space after the -d isp1.com before the backslash, then no white space after hitting enter (a mistake that I frequently make).

At any rate, now, whenever john  sends a message to gentoo-user@gentoo.org it will go through his isp1.com account.

If John belongs to several gentoo.org mailing lists, and wants to set this so that every email he sends to any list at gentoo.org is from isp1 then he could do this

```

send-hook ".*.gentoo-org" "my_hdr john@isp1.com"

send-hook ".*.gentoo-org" 'set sendmail="/usr/bin/nbsmtp -d isp1.com -f john@isp1.com -h smtp.isp1.com"'

```

This way, any mail going to an address ending with gentoo.org will be sent from the isp1 account.

If you don't have to do anything with your sendmail configuration but simply want to use a different from address, you can also simply hit 

```

E

```

before sending the email--this will let you edit your headers.

There is another method that might be more convenient for replying to private, as opposed to mailing list, emails.  Let's say that John usually uses his isp.com account, but at times also uses his isp1.com account.  He sends an email to Bill using the john@isp1.com address. Bill replies to him--the email, naturally enough, goes to john@isp1.com.  Now, John wants to reply to Bill--he also wants to continue this correspondence on the isp1.com account.  He could do this by adding more send-hook rules, but there is another way--this is another one that won't change the default sendmail setup, so if he must use a different smtp server it might not work.  However, in most cases, it shouldn't cause a problem.

Firstly, John will go to his .muttrc file.  When he first made the file, he put in the line

```

my_hdr From: John <john@isp.com>

```

As the my_hdr line here will override what we are about to do, he will use different syntax.  He will change that my_hdr line to read

```

set from="John <john@isp.com>"

```

Now he will also add these lines to his .muttrc

```

set reverse_name=yes

set alternates="john@isp1.com"

```

If he'd had a third account, he could have added that one using pipes, eg

```

set alternates="john@isp1.com|john@isp2.com"

```

The last time I set this up, it only worked if I entered it as shown above, with no white space between the email addies and the pipe.

He now has it set so that any emails addressed to john@isp1.com will be answered using the isp1.com address.  His default address will remain john@isp.com

Colors in mutt

I am not an expert on this, but will just give you a few ideas to get started.  Let's suppose that you want the headers to show different colors for the from to date and subject lines.  You can check the man muttrc for available colors, but the last time I looked, it didn't seem to have them all. 

Anyway, once again, open up your .muttrc file.  You can change these colors to suit your taste.   Add the lines

```

color header brightred black ^from

color header brightblue black ^to

color header brightcyan black ^subject

color header brightgreen black ^date

```

You will see, the next time that you open mutt that your from, to subject and date headers reflect the colors you added.   In case you're not sure what these meant, 

color, header obviously indicates that you're giving a color to the header.  Next are the foreground and background colors, for instance brightred on a black background.  The ^to  (again, this is case-insensitive) shows what aspect of the header that you want to change.

 There are many more things you can do with them, but this basic pattern works for me.

Spel-cheking, err, Spell Checking

While this is not part of mutt per se, it's a handy thing to have.  I use vi as my editor, and have also emerged ispell.  So, adding the following line to my .exrc enables me to spell check when composing email.

```

map <F6> :!ispell %^M:e %^M

```

Note that the ^M is actually a return character. When entering this into your .exrc with vi you would first hit ctrl + V

(more commonly shown as ^V) and then the return key. 

You'll also have to add this line to your .muttrc

```

set ispell="/usr/bin/ispell"

```

 Now, when composing email, if you hit F6, ispell will run, highlighting words that aren't in its dictionary.

Mutt and GPG

Rather than reinvent the wheel here, I'm going to send you to Justin Miller's page on this.  Towards the bottom of the page, he tells you what you should add to your .muttrc to have it work properly.  It can be cut and pasted--just be sure, if using vi, to set wrapmargin=0 and also be sure to replace his public key with your own.   :Smile: 

Also, note that Outlook Express users may receive your gpg signed emails as text attachments--this might be filtered by their network admins, etc.  There is a way around this, but I haven't looked into it.  It involves a patch and some reconfiguring.  Supposedly mutt 1.5 will handle it more easily.  The mutt faq mentions it and gives the solution of tell them to use a non-broken email client.  If the recepient is using Outlook Express and you can't get them to change to a non-broken client, then they'll either have to deal with it as a txt attachment or else you can send it clear.  

I'm showing a workaround below but NOTE This workaround seems to break GPG with standards compliant email clients.  At present, we have found that Sylpheed, for example, no longer sees an email sent as digitally signed if one applies the following patch.  (But I'm giving you a workaround for the workaround too)

The workaround involves applying a patch that can be found here, made by Mr. D. Woolridge.  Just copy the patch and save it somewhere--I saved it in my /home/scottro directory.   If you're unfamiliar with saving patches, then the easier way might be to go here and look towards the bottom of the page for pgp traditional patch for forcing text/plain (or something like that) right clicking and just saving it.

 I deleted my my /usr/portage/distfiles/mutt tarball and /var/tmp/portage/mutt directories.  Testing on another box showed that those steps weren't necessary, assuming you still have your /var/tmp/portage/mutt-version_number/work/mutt-1.4 directory.   Much of the following came from this thread.

I'm also found, with a bit of experimentation, that for the patch to work successfully, I had to remove the cjk flags from my USE variables in /etc/make.conf.  (This hasn't affected mutt's ability to read or input Japanese.)  As various things requiring root's permissions were involved, I did the entire process as root--I imagine that sudo would have worked as well, but didn't do it that way.  So, we're assuming that the patch, which is named patch-1.4.0 something is in my /home/scottro directory.

```

emerge -f mutt

ebuild /usr/portage/net-mail/mutt/mutt-1.4-r2.ebuild unpack

```

As mentioned above, if you already have your /var/tmp/portage/mutt-1.4.x/work/mutt-1.4 directory, the fetching and unpacking could be skipped.  Anyway....

Now that this is done, I go into the work directory and patch the source code.

```

cd /var/tmp/portage/mutt*/work/mutt-1.4

cp /home/scottro/patch-1.4.0* .

```

I've copied the patch into the work/mutt-1.4 directory.  There's a period at the end of that command, indicating current directory, which might be hard to see.   :Smile: 

When I had the cjk flags there, there was also a second directory in work, something like mutt-1.4-1ja (or something similar).  This is where I ran into problems.  Rather than experiment with several different ways of doing this, I would just say that if you have that directory, you should probably remove the cjk USE flags, remove your /usr/portage/distfiles/mutt*, rm -rf your /var/tmp/portage/mutt* and start with emerge -f and the ebuild unpack command that I've already discussed. 

```

patch -p0 < patch-1.4.0*

cd 

```

The cd is just my habit--I doubt that it would make any difference.

```

ebuild /usr/portage/net-mail/mutt/mutt-1.4-r2.ebuild compile

ebuild /usr/portage/net-mail/mutt/mutt-1.4-r2.ebuild install

ebuild /usr/portage/net-mail/mutt/mutt-1.4-r2.ebuild qmerge

```

Lastly, we have to add a line to .muttrc. I would only do this if most of your mail is sent to OE and other non-complient client users. 

```

set pgp_create_traditional="yes"
```

Your OE using friends will now receive your gpg signed messages as inline text rather than an attachment.

However, as mentioned, your tech friends will not receive properly signed emails. Therefore, rather than add the above line into your .muttrc and commenting it out, then uncommenting it, which can definitely be a nuisance, leave the line out of .muttrc. On the occasions when you do need it then, before sending your mail do

```

: set pgp_create_traditional="yes"

```

That's a colon, then the line that could be added to .muttrc.  A colon indicates that the following line should be read as if it were part of your .muttrc

A few more quick notes here.  If you mistype your pgp passphrase, then hit ctrl+shft+F and the passphrase will be forgotten, enabling you to enter it again.  Also, before hitting y for send, if you hit p a GPG menu comes up--you can choose to sign (which would be the default if you use Mr. Miller's .muttrc) encrypt and sign, sign as, or forget it.  If you choose f for forget it, it wil be sent without GPG signing for your OE using friends. 

Hopefully, this will get you started, and give you an idea of the

power of mutt

Mod edit: Changed greaturl.com to example.com on request by owner of greaturl.com.  --kallamej, 2005-03-15Last edited by scottro on Fri Oct 15, 2004 10:58 pm; edited 9 times in total

----------

## whit

In running with this setup I've discovered that nbsmtp does not handle To addresses right if they are in the form of 

```
"Last, First" <flast@some.com>
```

which nbsmtp parses as two addresses

```
"Last
```

 and 

```
First" <flast@some.com>
```

 which will result in nbsmtp apparently working, but the downstream mail server most likely complaining about unbalanced quotes and failing to send the mail onto anywhere. This can be worked around by making sure there is no comma within quotes in e-mail addresses. 

Or qmail can be installed fairly simply for outgoing mail. See https://forums.gentoo.org/viewtopic.php?t=14132 for notes on that. In particular, be sure the svscan daemon is running even for outgoing mail. If using qmail with the setup above, comment out the lines to invoke nbsmtp from .muttrc if you've added them per the main doc here. For incoming mail there's still an advantage to feeding from fetchmail directly to procmail, as qmail needs extra setup to use procmail, and procmail is very handy for sorting mail and anti-spam.

Just in case you're blending this with instructions in the Fetchmail docs, the form of procmail invocation above works well in .fetchmailrc 

```
mda "/usr/bin/procmail -d %T"
```

 while an alternate form suggested in one of the Fetchmail doc examples 

```
and wants mda /usr/bin/procmail
```

has the flaw, if you're using mbox-format mail files, of not writing an initial From line, which results in mutt not seeing the mail.

----------

## microbrain

Newest versions of fetchmail (mine says 6.1.2+RPA+NTLM+SDPS+SSL+NLS)

seem to prefer encrypted protocols.

If your pop server doesn't support encryption you'll get errors these:

fetchmail: SSL connection failed

fetchmail: Authorization failure on john@isp.com

fetchmail: Query status=3 (AUTHFAIL)

The solution is to specify you want to use cleartext for authentication in your .fetchmailrc, like this

(before)

poll pop.somewhere.org proto pop3 user john password "1234"

(after)

poll pop.somewhere.org proto pop3 auth password user john password "1234"

Hope this helps somebody

----------

## Lockup

hmm the ".fetchmail: SMTP connect to localhost failed" error msg...is there a way to remove it? its not affecting me in any way, as you pointed out in the howto, but i tend to like not seeing errors happening...maybe some var somewhere i could remove i dunno, any idea?

----------

## scottro

I only looked into it when it first happened, and googling indicated that most people just ignored it or were running something like sendmail.  So, I've never looked more deeply into the answer--if someone has it, please post it and I'll incorporate it into the article.  However, as mentioned in the article, I think that if you run postfix, sendmail or the like, you won't have the problem.  

Scott

----------

## Zu`

the correct ssmtp path is:

```

/usr/sbin/ssmtp

```

----------

## scottro

A followup to the question on error messages.

If one uses getmail instead of fetchmail, you won't get the error messages. I'm working on a getmail page, but it's fairly simple to configure--the only thing that might not be clear from a sample configuration file is that if one were using procmail, the postmaster entry should read

```

postmaster = "|/usr/bin/procmail"
```

Hope this is of use to someone

Scott

----------

## Empty_One

 *Quote:*   

> Scottro said:For those not familiar with crontab, there are 6 fields---minute hour day week month and the command to be run. If you don't want to specify a particular field, you can use an asterisk. So, we're going to set getmail to run every ten minutes.
> 
> After the previous command, your default text editor should have opened. If you're using nano, be careful of the wordwrap. So, since we're only worried about minutes, we're going to simply indicate the other fields with asterisks. In the text editor type
> 
> ```
> ...

 

I'm using vcron also, but when I copied your code exactly, I received errors from contrab about an error reading the hour.  I had to change it to this for it to work properly:

```

10,20,30,40,50,00 * * * * /usr/bin/getmail

```

Other than that, it was perfect (as far as I could tell).  I finally got mutt up and running, with all my mail sorted and everything.  Thanks alot.

Now all I have to do is figure out how to ssh into this machine thru works proxy so I can read my mail.   :Smile: 

----------

## scottro

You are quite correct--I mistyped it.  The error has been rectified (with a note that it was originally mistyped.)  Thanks very much for pointing it out to me, and I'm glad the rest of the article was helpful.

Scott

----------

## BackSeat

Another way of writing the cron entry, which some may consider cleaner, is:

```
*/10 * * * * /usr/bin/getmail

```

BS

----------

## scottro

I actually like that method better and it will be put in the article within a few hours.

Scott (who didn't read the man page carefully enough and missed that one)

----------

## S_aIN_t

I have gone through the tutorial but there is one problem. Procmail concatenates mail based on the filtering rules, instead of placing it into a folder with that name. 

Example: I have a rule that says 

```

:0 

* ^TO_tech@openbsd.org

IN-techOpenBSD

```

when i get new mail, anything that matches that rule goes into a single file called IN-techOpenBSD instead of a directory with the same name. I've gone over the config files a couple of times.. but there i cannot see anything being wrong with them.

any thoughts on what could be wrong?

----------

## scottro

It looks correct to me. Is it only with the openBSD mail, or all mail?

Hopefully, someone else can jump in on this, I'm stumped

----------

## S_aIN_t

i got some help in the local lug irc channel.. i wa told that by default procmail uses the mdir format.. (the one where all the messages get appended to one file) to force procmail to create a new folder i had to add a "/" to the mailbox name. 

so if i had this in .procmailrc 

```

:0 

* ^TO_tech@openbsd.org

IN-techOpenBSD

```

it is now changed to 

```

:0 

* ^TO_tech@openbsd.org

IN-techOpenBSD/

```

Now i have the  folders created and it is all working.  :Very Happy:  Thanks for a great guide.. I dont have to rely on KDE's Kmail anymore..

----------

## RealisticDragon

Is there a Qmail howto anywhere on creating an adequatly secured configuration (sending only from the local machine, or possibly from a list of IP addresses) as I have no desire to run an open relay for every spammer in the world :o)

I am planning on using getmail for recieving, so that isn't required with qmail (except how to disable it).

Thanks,

----------

## bludger

Does getmail support pop-ssl?

----------

## bludger

 *bludger wrote:*   

> Does getmail support pop-ssl?

 

I have found a link which seems to answer my question.  

https://forums.gentoo.org/viewtopic.php?t=36034&highlight=getmail+stunnel

Any success stories with this configuration?

----------

## bludger

I finally decided upon using fetchmail and procmail, since fetchmail has ssl support integrated (no need for an stunnel daemon) and procmail seems to support maildirs fairly well.  This seems to work fairly well for mail reception.  

For sending mail, I am a bit stuck.  My MSP (mail service provider ?) supports 

LOGIN authorisation + TLS.  Does anyone know whether nbsmtp supports such authorisation, or do I have to use a mail server such as postfix (which I would rather not do, as it is yet another layer of complexity and would have to be running all the time, which is yet another security risk).  

Any ideas?  I have not been getting many answers to my questions lately.  Is it that they are too hard or too stupid?

----------

## jkalderash

Hello, 

This is a wonderful tutorial, and I'm very happy with what mutt is able to do.  I have one major problem, though - I am unable to carbon-copy outgoing messages.  As far as I can tell, if the message has a CC field, nothing gets sent, which is very frustrating.  I've got the "sendmail" line set up as specified:

```
set sendmail="/usr/bin/nbsmtp -d mycollege.edu  -f username@mycollege.edu -h mail.mycollege.edu"
```

I'm sure I have the correct server name and all (obviously I've changed it here).  Does anyone know what might be causing this, how I can proceed, or any simple alternatives I can use?  I really like having just one line in my muttrc...

----------

## scottro

Thanks for the kind words.  

You should, once the email is finished and ready to send, just be able to hit 

```

c

```

type in the cc'd recepient's email and it should work.

I don't maintain this page any more, as there is another guide in the main Gentoo docs.  However, I have found (dont think it's mentioned in this article) that nbsmtp seems to have a limit of  only a few names that it can send at a time.  You might want to switch over to ssmtp.

I have a non-specific gentoo mutt article that I do keep more up to date at

http://home.nyc.rr.com/computertaijutsu/mutt.html

Scott[/code]

----------

## jkalderash

Thanks for the advice.  I actually just ended up using mutt's own software - I commented out the "sendmail" line and added a line:

```

set hostname="mail.mycollege.edu"

```

Seems to work like a charm.  Thanks!

-Laura[/code]

----------

## chris.pickett

Hi.  I liked and used your guide too, but I must say that nbsmtp does have its fair share of problems, including what I think was silently dropping mail on some occasions or forwarding mail to the wrong address (ouch!).  I know this is out of date anyway, but I just used this guide, and so anyone else using it:  nbsmtp is unmaintained, try postfix instead.  Cheers!

----------

## dkaplowitz

Hi,

Great guide. I've used it periodically to help me with various things in this set up. I'm currently having a strange problem with my mail sending successfully, but as my local computer username rather than as my mail username, which is different.

In my .muttrc I have the following:

```

set from="David Kaplowitz <david.kaplowitz@thistestdomain.com>"

```

Which is the correct e-mail username I want to send as....but it's not sending as that username, it's sending as my local login which is just "dkap"

```

root=postmaster

mailhub=smtp

rewriteDomain=thistestdomain.com

hostname=david-kaplowitz.thistestdomain.com

UseSTARTTLS=YES

```

hostname is the name of my local computer.

I'm searching around ...trying to find an answer to why my .muttrc setting is not working.

Thanks for any clues.

Dave

----------

## dkaplowitz

 *dkaplowitz wrote:*   

> I'm currently having a strange problem with my mail sending successfully, but as my local computer username rather than as my mail username, which is different.

 

nm, I got it working by uncommenting this: FromLineOverride=YES from /etc/ssmtp/ssmtp.conf

----------

## dkaplowitz

 *scottro wrote:*   

> mutt and the Single User
> 
> Lastly, we have to add a line to .muttrc. I would only do this if most of your mail is sent to OE and other non-complient client users. 
> 
> ```
> ...

 

I've set the 

```

set pgp_create_traditional="yes"
```

 in my .muttrc and my mutt client doesn't show this as being broken, and it's working for non-RFC 2015-compliant mail clients. I'm wondering if it's because it emanated from mutt. I guess I can try it on another RFC 2015 compliant mail client to be sure.

I'd be curious to know if anyone's successfully using this setting without showing the sig as broken in _real_ mail clients.

Dave

----------

## paramthegreat

hi,

thanx a lot for this great guide. It had got me started on mutt. but i am having problems filtering with procmail. i have 3 email accounts and 2 mailing list that belong to a single email account. i want that emails of each of 3 diff accounts goto diff folders. 

i tried using the following code but no luck

```

:0

* ^To_psg0217@omega\.uta\.edu

IN-omegamail\

:0

* ^To_psg0217@exchange\.uta\.edu

IN-exchangemail\

:0

* ^To_paramthegreat143@hotmail\.com

IN-paramthegreat\

:O

* ^To_parminder_gupta@hotmail\.com

IN-parminder\

:0

* ^To_rox-devel

IN-paramthegreat\

:0

* ^To_JAI_INTEREST

IN-paramthegreat\

```

all i get is unfiltered mail in my inbox. it would be great if someone could help me with this.

thanx a lot,

parminder.

----------

## nsahoo

is it just me or these guys in forums have some real talent in writing "how to"s for n00bs like me.

thanks m8

----------

## dkaplowitz

 *paramthegreat wrote:*   

> 
> 
> ```
> 
> :0
> ...

 

If you are using .maildir format, then I think you need to define your target folders thus:

```

IN-paramthegreat/

```

Try that, and you might get different results.

Here's an example from my .procmailrc:

```
:0

* ^TO_bugtraq@*

ML_bugtraq/

```

----------

## paramthegreat

nope it does not seem to work either. i cannot figure out whats wrong. i guess i will have to dump mutt & procmail in favor of thunderbird if this does not work.

----------

## dkaplowitz

 *paramthegreat wrote:*   

> nope it does not seem to work either. i cannot figure out whats wrong. i guess i will have to dump mutt & procmail in favor of thunderbird if this does not work.

 

If T-bird's the easy way out and that's what you prefer, go for it. I'm curious to know if you're initializing mutt with the -y option. Also, are the folders being created in your .maildir? (Do you see folders created for the rules you defined in .procmailrc?)

----------

## paramthegreat

i would rather use mutt if i can get it working. also i cannot c any folders being made according to the rules i defined.  it seems that procmail does not do any processing on the mails, just dumps them in the .maildir folder.

----------

## dkaplowitz

 *paramthegreat wrote:*   

> i would rather use mutt if i can get it working. also i cannot c any folders being made according to the rules i defined.  it seems that procmail does not do any processing on the mails, just dumps them in the .maildir folder.

 

I think you'll be happier if you stick with mutt...it's very rewarding...and powerful to use.

I get the feeling your procmail is not even doing anything.... are you sure it's being called right by your (I'm assuming you use) fetchmail config? 

Here's what I use to get my mail:

```
 fetchmail -av -m "/usr/bin/procmail -d %T" 

#leaves messages on the server
```

Are you sure you have the right path to procmail here? Maybe you could post your configs for us to troubleshoot.

thanks,

Dave

----------

## paramthegreat

hi,

thanx everyone for all the help that is being offered. i am using getmail to fetch my mails cause it is simple to configure. i am going to post my configs here and c if that will help

here is my .getmail/getmailrc:

```

[default]                           # This section provides default arguments and values,

                             #    and variables which can be used in other sections

verbose = 1                       # Be verbose by default

readall = 0                         # Retrieve only new messages by default

delete = 0                          # Delete mail after retrieval by default

message_log = /var/log/getmail.log  # Log message retrieval and delivery to this file by default

timeout = 240                       # TCP timeout value; increase if on a poor connection or

                                            #    slow POP3 server.  getmail defaults to a 180 second timeout.

max_message_size = 1048576          # Don't retrieve messages over 1MB (MiB).  Default is 0, which

                                    #    means no limit.

[omega mail]                        # Simple configuration for a single-user POP3 mailbox

server = omega.uta.edu

port = 110

username = psg0217

password = xxxxxxxxxx      # no password specified; prompt for it when                                      #getmail is run

use_apop = 0                        # Use APOP authentication for this account instead of

                                    #  cleartext PASS

postmaster = "|/usr/bin/procmail"   # Default delivery to this Maildir

message_log = ""                    # Don't log for this account

                                    # No "local" directives necessary.

recipient_header = received         # For this account, only look for recipient headers

recipient_header = x-envelope-to    #   in "Received:" and "X-Envelope-To:" headers 

no_delivered_to = 1                 # Don't add a Delivered-To: header for this mailbox

no_received = 1                     # Don't add a Received: header for this mailbox

[exchange mail]                     # Simple configuration for a single-user POP3 mailbox

server = exchange2.uta.edu

port = 110

username = psg0217

password = xxxxxxxxx

                                     # no password specified; prompt for it when getmail is run

use_apop = 0                         # Use APOP authentication for this account instead of

                                     #   cleartext PASS

postmaster = "|/usr/bin/procmail"    # Default delivery to this Maildir

message_log = ""                     # Don't log for this account

                                     # No "local" directives necessary.

recipient_header = received          # For this account, only look for recipient headers

recipient_header = x-envelope-to     #   in "Received:" and "X-Envelope-To:" headers 

no_delivered_to = 1                  # Don't add a Delivered-To: header for this mailbox

no_received = 1                      # Don't add a Received: header for this mailbox

```

for now all i want is to get the mails placed in different folders. i know that procmail is called properly because as in the getmailrc; its procmails job to put mails in .maildir, i do not think that it is doing any filtering. i am not sure if that is related to my .procmail or something else.

thanx,

parminder.

----------

## Shemite_Dog

Thanks for the great guide!!

I have one small problem though.  From my home pc, everything works just  fine, but  when I use putty to login from my friends house I have a problem with html mail. They render  fine in the preview pane, but when I press control-b, for w3m to "take over" I just see the raw html,  not rendered. This has been frustrating me for two months. I've tried a few different mailcap and .muttrc entries but nothing works.  I'd apreciate any insights as to why I can't get this working.   :Very Happy: 

Here's what I think are the relevant snippets of my mailcap and .muttrc

mailcap:

```

text/html; w3m %s; needsterminal; description=HTML Text; nametemplate=%s.html

text/html; w3m -dump %s; copiousoutput; description=HTML Text; nametemplate=%s.html

```

.muttrc:

```

macro index \cb |w3m\n "call w3m to extract URLs from a message"

macro pager \cb |w3m\n "call w3m to extract URLs from a message"

```

----------

## dkaplowitz

 *Shemite_Dog wrote:*   

> Thanks for the great guide!!
> 
> I have one small problem though.  From my home pc, everything works just  fine, but  when I use putty to login from my friends house I have a problem with html mail. They render  fine in the preview pane, but when I press control-b, for w3m to "take over" I just see the raw html,  not rendered. This has been frustrating me for two months. I've tried a few different mailcap and .muttrc entries but nothing works.  I'd apreciate any insights as to why I can't get this working.  
> 
> [/code]

 

Do you have this defined in your .muttrc?:

```

auto_view text/html
```

Put it directly beneath your "macro pager" declaration. That's what worked for me.

----------

## BlinkEye

am i the only one who uses several mailaccounts and hence subfolders within ~/.maildir? i'm curious on how to convince mutt to read all my subfolder and not only one. i figured out that

```
#set spoolfile=~/.maildir/.INBOX
```

in ~/.muttrc sets the box it reads mail from. unfortunately you can't simply add several spoolfiles as mutt only evaluates the last one specified. any suggestions?

----------

## mirko_3

I used this guide a couple months ago, but didn't post any feedback - I'll do it now: very clearly written, very useful too.

One problem that emerged recently is with mailboxes and Imap: I've searched the web for hours, but couldn't find I could configure mailboxes on impa accounts, so that pressing c would work nice (automatically select mailbox with new mail and stuff)

That is, I've found that you could specify Imap folders in a mailboxes (in muttrc)  directive, but it doesn't work... any help is gratefully accepted, but it's not a critical feature...

Again, great guide, thanks a lot!

----------

## AgenT

 *BlinkEye wrote:*   

> am i the only one who uses several mailaccounts and hence subfolders within ~/.maildir? i'm curious on how to convince mutt to read all my subfolder and not only one. i figured out that
> 
> ```
> #set spoolfile=~/.maildir/.INBOX
> ```
> ...

 

Set your spoonfile to your main email folder under ~/.maildir like so:

```
set spoolfile="~/.maildir/mailbox1"
```

Then set the mailboxes variable like so:

```
mailboxes ! =mailbox1 =mailbox2 =mailbox3
```

That is all. Then use (the default) button 'c' to change between your mailboxes. The neat part about mutt is that it will auto fill mailboxes that have new emails in them. Hence you can start mutt, 'tab' your way to all the new emails in your default mailbox, press 'c' which will fill in the next mailbox that has new emails, press enter, and repeat.

If you have more than one mailbox, you should learn to use hooks. They are very useful.

----------

## BlinkEye

thanks a lot for your answer. this is exactly what i've been looking for and mutt makes it even better. unfortunately i'm doing something wrong as mutt doesn't like my settings. i'll post what i've tried:

~/.muttrc

```
# pts/172 cat .muttrc

set spoolfile=~/.maildir/

mailboxes ! =.BlinkEye
```

INBOX or .INBOX or cur doesn't work for the main spoolfile. neither .BlinkEye nor *fullpathto*blinkeye works. thanks for the hint with the key "c" - i'm now able to select my mailboxes - but not automatically or displayed via the "?" key pressed after "c" but typed in manully.

----------

## AgenT

 *BlinkEye wrote:*   

> thanks a lot for your answer. this is exactly what i've been looking for and mutt makes it even better. unfortunately i'm doing something wrong as mutt doesn't like my settings. i'll post what i've tried:
> 
> ~/.muttrc
> 
> ```
> ...

 

Are you saying that .maildir/ is actually a real mailbox? If so, I suggest you create a default/private maildir under that folder. So for example, if you have two mailboxes, your file structure would look something like this:

```

.maildir

|_ new

|_ cur

|_ tmp

|_ mailbox1

   |_ new

   |_ cur

   |_ tmp

   |_ .sent (optional)

      |_ new

      |_ cur

      |_ tmp

|_ mailbox2

   |_ new

   |_ cur

   |_ tmp

   |_ .sent (optional)

      |_ new

      |_ cur

      |_ tmp

```

The new, tmp, and cur right under maildir would not be used since you will not be using the maildir folder as an actual mailbox. However, these folders are needed or mutt may have problems. 

Here is the minimum .muttrc file for the above setup:

```

set spoolfile="~/.maildir/mailbox1"

set folder="~/.maildir"

mailboxes ! =mailbox1 =mailbox2

```

If you opt for the .sent folder you will have to tell mutt to send all sent emails to it using folder hooks (set record="full path to .sent folder").

Please note that you may have problems if you make these directories by hand. You should use the maildir folder creation program:

```
man maildirmake
```

I suggest you backup your .maildir folder (mv ~/.maildir ~/.maildir_backup) and start "over". Once everything works in mutt, just copy all email inside the folders in ~/.maildir_backup to ~/.maildir. Keeping newly made folders that were created by maildirmake intact. This means you would be moving only actual email files over and putting them in their corresponding directories.

----------

## BlinkEye

well, now i see the problem. the problem is that my mailboxes start with a ".", i.e. "~/.maildir/.mailbox1", "~/.maildir.mailbox2". if i set 

```
set folder="~/.maildir/.mailbox1"
```

i lose the ability to open my other (hidden) mailboxes via "c" and typing in ".maliboxX". i just created a new not hidden mailbox via maildirmake which works for mutt. but is it somehow possible to switch my mailboxes?

----------

## AgenT

 *BlinkEye wrote:*   

> i just created a new not hidden mailbox via maildirmake which works for mutt. but is it somehow possible to switch my mailboxes?

 

Not sure what you are asking. Do you want to know how to switch between mailboxes inside of mutt or how to physically move all your emails from the old mailbox to the new one which was made by maildirmake?

When you use 'c' to switch mailboxes, all you have to do is type in 

```
=mailbox1
```

 to switch. Notice the '=' which is exactly how it should be listed in your muttrc file.

It is actually very fast because if you have new mail mutt will fill in that blank by itself. If you want to switch to a mailbox that does not have new emails in it, all you have to do is type the = and the first or so letter of the mailbox followed by the 'tab' key (tab-completion). Easy and fast! mutt is by far the fastest email client out there especially once you have made a few configuration changes to suite your needs better.

----------

## Benji-Boy

Hey guys,

I was browsing the forums looking for any mutt configuration tips for Qmail.

There is a Qmail HowTo setup  here  : which recommends the use of  "mutt" to browse emails, but the details on how to configure mutt for this purpose are non existent.

could someone please post some helpful code?

----------

## Andersson

 *Benji-Boy wrote:*   

> Hey guys,
> 
> I was browsing the forums looking for any mutt configuration tips for Qmail.
> 
> There is a Qmail HowTo setup  here  : which recommends the use of  "mutt" to browse emails, but the details on how to configure mutt for this purpose are non existent.
> ...

 

mutt -f ~/.maildir opens your mailbox, if ~/.maildir is what you call it. If you'll be using mutt as your default email client, you'll probably want a configuration file. Look for examples on the mutt web page http://www.mutt.org/

----------

## Benji-Boy

Thanks for the help.

Much better now.

 :Cool: 

Does anyone know a mail client which can be configured to show the entire page source?

I am really interested in being able to get information from the header of the emails such as:

encryption eg Base64 or Base 8.

If it is of mixed type or contains just text.

Originating IP, sender url etc.

text font colour and backgroung colour within the html tags.

I am trying to build a SPAM filter which uses these features but the only email client I have found which gives a comprehensive description of the RAW source is MSN hotmail euck!

Benji-Boy

----------

## Andersson

 *Benji-Boy wrote:*   

> Does anyone know a mail client which can be configured to show the entire page source?
> 
> I am really interested in being able to get information from the header of the emails such as:
> 
> encryption eg Base64 or Base 8.
> ...

 

All your mail is saved on disk as text files, the entire email including all the headers are of course in these files.

If you want to see all the headers in mutt, press h. You can set up which headers to be shown in default mode in the config file, example:

```
ignore *                        # Ignore all header info

unignore subject                # Except the following

unignore to

unignore from:

unignore date

unignore CC

unignore X-Spam-Level
```

----------

## AgenT

Also, if you press e you will be able to see/edit (in your set editor) the whole email source.

----------

## Benji-Boy

Thanks Agent T and Andersson.

This makes my life much easier.

I have finished the text parser which tokenises the features i am interested in as neural network inputs. It is just really annoying getting tripped up by little things that take time to lookup and find out how to get around.

Excellent support on these forums and very quick responses,

I really appreciate it.

Regards,

Benji-Boy

----------

## crimson

This is really informative.  Thanks.

----------

## Xaid

This is a good guide, thanks. One question though, if I use nbsmtp/ssmtp/msmtp and define the different smtp servers that I can send mail to, what happens for local mail? what I'm trying to say is, say I have programs which email logs to root@localhost, will using this setup break them?

Edit: nevermind, I thought msmtp would be blocked by postfix   :Embarassed: 

----------

## gargola

Hi, 

I am having the following problem. I have mutt with the following flags emerged:

 *Quote:*   

> USE="-cjk +crypt -debug +imap -mbox +nls -nntp +sasl -slang +ssl -vanilla"

 

UTF & 8859-1 & 8859-15 character maps are compiled into kernel

normal text console does support characters such as ä ü ö ß ñ etc. 

When I write my emails (vim) I can write these characters w/o a problem at all, however whenn I get back into the email they are displayed as \344 \3?? etc.

This problem is a mutt poblem since it appears to be only in mutt.

I already tryed: 

 *Quote:*   

>  ajs@b30a ajs $ export LANG=en_US.UTF-8
> 
> ajs@b30a ajs $ locale
> 
> LANG=en_US.UTF-8
> ...

 

but that did not work either.

Any ideas? reemerge glibc ?????

----------

## micmac

Do you use vim as editor? If so you can try this .vimrc:

```

set fileencodings=iso-8859-15

set fenc=iso-8859-15

set enc=iso-8859-15

set tenc=iso-8859-15

```

Adapt to your charset of course. Gentoo devs changed the default config to UTF-8. That got me into some trouble myself.

----------

## arazaxirelcinellersadolur

hi,

i installed exim4+fetchmail+procmail+mutt for accessing my gmail emails to my laptop.

at the beginning fetchmail bring the all (?) messages from gmail account.

but a day later, i can not receive any mail from my account and i do not why?

i send 2 screenshots about that fetchmail and my account says a DiFFERENT things.

also, i am sending all my .*rc files according to this matter.

i hope that there is someone can help me with this matter , because i tried thunderbird and evo. but those made the same thing after first bringing emails. especially thunderbird sucks, with his .lock file - i can not delete it, because when i run thunderbird it appear, when i click on it to delete --suddenly it disappear   :Sad: 

the screenshots and the .*rc files are here:

1- http://www.ubuntuforums.org/attachment.php?attachmentid=5682&d=1138627520

2- http://www.ubuntuforums.org/attachment.php?attachmentid=5683&d=1138627520

3- .*rc files: http://www.ubuntuforums.org/attachment.php?attachmentid=5687&d=1138634142

p.s.

can u imagine that google mail causes that i do not receive my emails?   :Rolling Eyes: 

arazaxirelcinellersadolur@gmail.com

elcinmemmedzade@yahoo.com

----------

