Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

My .muttrc file looks something like this one or see below a glimpse. I am hesitant with the password. How should I store my password to use it with mutt?

set imap_user = ""
set imap_pass = "password"

set smtp_url = "smtp://"
set smtp_pass = "password"
set from = ""
set realname = "Your Real Name"
share|improve this question

migrated from Sep 12 '11 at 22:28

This question came from our site for computer enthusiasts and power users.

In the post you linked, I already wrote "Make sure your ~/.muttrc isn’t world-readable; it contains your password. (Alternatively, you can leave them out and mutt will prompt you for the password each time.)" :-) – ShreevatsaR Jul 18 '10 at 16:36

3 Answers 3

up vote 28 down vote accepted

This tweak should get rid of your problem. Use gpg as suggested, or

set imap_pass=`getpassword email_id`

where you use pwsafe or passwords to fetch the passwords.

Edit: If mutt is built with IMAP support (--enable-imap), then mutt should prompt you for the password if you do not set it in the config file. From the manual:


Type: string Default: ""

Specifies the password for your IMAP account. If unset, Mutt will prompt you for your password when you invoke the fetch-mail function. Warning: you should only use this option when you are on a fairly secure machine, because the superuser can read your muttrc even if you are the only one who can read the file.

share|improve this answer
+1 have mutt ask you for it. You should only have to enter it once per session. – David Mackintosh Aug 28 '09 at 14:08
Also, if you run mutt within tmux, your session can last a while. – Chris W. May 29 '13 at 17:03
What is this function getpassword? I do not have it in my Ubuntu 14.04.3 LTS (GNU/Linux) server. I think they are pwsafe or passwords but I should I use them? I would like to be logged into my mutt -account without password once I am logged into the server, since the password of the server is the same as the email's one. – Masi Oct 21 at 11:58

Create a passwords file: ~/.mutt/passwords:

set imap_pass="password"
set smtp_pass="password"

This file can be encrypted using GPG. First, create a public/private key pair:

$ gpg --gen-key

Encrypt the passwords file:

$ gpg -r -e ~/.mutt/passwords
$ ls ~/.mutt/passwords*
/home/user/.mutt/passwords   /home/user/.mutt/passwords.gpg
$ shred ~/.mutt/passwords
$ rm ~/.mutt/passwords

Add to your muttrc:

source "gpg -d ~/.mutt/passwords.gpg |"


See also Arch Wiki's Mutt entry.

share|improve this answer
Should the public key in the passwords file or the shell script? I think the shell script should be in .muttrc. I get after running the gpg command gpg: skipped: public key not found gpg: /u/77/masi/unix/.mutt/passwords: encryption failed: public key not found. I did cat $HOME/.ssh/ >> $HOME/.ssh/known_hosts but it does not seem to be the problem. What do I do wrong? – Masi Oct 21 at 11:58
Masi, you need to have a GPG (or PGP) key, not your SSH public key. More info on GPG keys here: and here: – DmitrySandalov Nov 12 at 21:24

Based on ShreevatsaR's comment, I want to emphasize security. If password in $HOME/.muttrc, do

chmod go-r $HOME/.muttrc

However, I think this is not a secure option still. You should use some method which uses salt in storing passwords.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.