4

I'm trying to send and e-mail from mutt from command line using following command:

mutt -F /my/path/to/muttrc -s "Hello" an@email.com < test.txt

But nothing happens. Mutt doesn't display any error but mail it's not sent.

Everything works fine if I enter interactive mutt using mutt command and send the e-mail from there.

In my muttrc I have configured a gmail account, like this:

account-hook    imaps://a_user@imap.gmail.com 'set imap_user=a_user@gmail.com imap_pass="password"'
folder-hook     'imaps://a_user@imap.gmail.com' 'set folder=imaps://a_user@imap.gmail.com/'
set folder=imaps://a_user@imap.gmail.com/
mailboxes +INBOX
set spoolfile = +INBOX
folder-hook    imaps://a_user@imap.gmail.com 'set smtp_url="smtps://a_user:password@smtp.gmail.com"'
folder-hook     'imaps://a_user@imap.gmail.com' 'set from=a_user0@gmail.com'
folder-hook    imaps://a_user@imap.gmail.com 'set realname="A Real Name"'

set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
unset record
set timeout=15
set mail_check=60
set imap_keepalive = 900
unset imap_passive
set move = no
set sort = 'last-date-received'
set charset=utf-8
set locale=$LANG
send-hook "~f a_user@gmail.com" 'set signature="~/.mutt/signature"'
set editor = 'vim'
4

Looks like you're setting smtp_url only in a folder-hook. That means that its only set when you use that folder, and when you're using the non-interactive command line method, it never actually tries to access the folder, so smtp_url isn't ever set, so it has no idea what method to send messages. It might be defaulting to some other method (like piping to sendmail) and failing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.