mutt: Error sending message, child exited 127 (Exec error.)
Asked Answered
T

5

23

I have to send a mail with an attachment from a shell script. I am trying to do it using mutt as shown here: How do I send a file as an email attachment using Linux command line?

Command: echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- [email protected]

Error:

Error sending message, child exited 127 (Exec error.).
Could not send the message.

Tenter answered 15/4, 2016 at 5:59 Comment(1)
Do you install msmtp, or something else used to send mail?Obligor
F
24

I was having the same issue on Ubuntu 18.04 and just like @jono, I only had installed mutt. Installing

sudo apt-get install sendmail

After that, sending mail with the test method or straight through the mutt CLI worked perfectly.

Fleury answered 21/2, 2019 at 18:0 Comment(0)
W
4

I had this error and had to simply add below to my .muttrc. I'm using Gmail if that matters. This way I'm using someone elses server to send and don't have to install extra junk.

set smtp_pass="secrets" set smtp_url = "smtps://[email protected]@smtp.gmail.com:465/"

Warlord answered 15/6, 2018 at 19:53 Comment(0)
U
3

I have encountered this same error today. I found I only had mutt installed, but once I installed sendmail this error went away. However I then got blocked locally. So I uninstalled sendmail, and installed postfix this worked.. Now receiving email with attached pdf.

This was on RHEL 7.4 in an enterprise environment. Unsure if results will differ on other versions or environments.

Unquiet answered 23/3, 2018 at 2:51 Comment(0)
M
1

set the password generated from this link into this file:

    # file: ~/.muttrc
    set from="[email protected]"
    set realname="first_name last_name"
    set imap_user="[email protected]"
    #
    # v1.0.1
    # check the following google help page:
    # http://support.google.com/accounts/bin/answer.py?answer=185833
    # that is set here your google application password
    set imap_pass="SecretPass!"
    #nopeset imap_authenticators="gssapi"
    set imap_authenticators="gssapi:cram-md5:login"
    set certificate_file="~/.mutt/certificates"
    #
    # These two lines appear to be needed on some Linux distros, like Arch Linux
    #
    ##REMOTE GMAIL FOLDERS
    set folder="imaps://imap.gmail.com:993"
    set record="+[Gmail]/Sent Mail"
    set spoolfile="imaps://imap.gmail.com:993/INBOX"
    set postponed="+[Gmail]/Drafts"
    set trash="+[Google Mail]/Trash"
    #
    ###SMTP Settings to sent email
    set smtp_url="smtp://[email protected]:587"
    #
    # v1.0.1
    # check the following google help page:
    # http://support.google.com/accounts/bin/answer.py?answer=185833
    # that is set here your google application password
    set smtp_pass="SecretPass!"
    #
    ###LOCAL FOLDERS FOR CACHED HEADERS AND CERTIFICATES
    set header_cache="~/.mutt/cache/headers"
    set message_cachedir="~/.mutt/cache/bodies"
    set certificate_file =~/.mutt/certificates
    #
    ###SECURING
    set move=no  #Stop asking to "move read messages to mbox"!
    set imap_keepalive=900
    #
    ###Sort by newest conversation first.
    set sort=reverse-threads
    set sort_aux=last-date-received
    #
    ###Set editor to create new email
    set editor='vim'

    set ssl_starttls=yes
    set ssl_force_tls=yes
Moujik answered 16/8, 2018 at 18:29 Comment(0)
S
1

Fix for GMail Account Configuration

The following post worked for me: https://www.codyhiar.com/blog/getting-mutt-setup-with-gmail-using-2-factor-auth-on-ubuntu-14-04/

But it was not very clear. The contents of ~/.muttrc that worked for me are as follows (My account has 2-Step verification enabled and I had to generate app password as described in the post):

set imap_user = "<username>@gmail.com"
set imap_pass = "<16-character-app-password>"

set sendmail="/usr/sbin/ssmtp"

set folder="imaps://imap.gmail.com:993"
set spoolfile="imaps://imap.gmail.com/INBOX"
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"

set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"

set from = "<username>@gmail.com"
set realname = "<name-used-in-the-gmail-account>"

set smtp_url = "smtp://<username>@smtp.gmail.com:587/"
set smtp_pass="<16-character-app-password>"

set move = no
set imap_keepalive = 900

# Gmail-style keyboard shortcuts
macro index,pager ga "<change-folder>=[Gmail]/All<tab><enter>" "Go to all mail"
macro index,pager gi "<change-folder>=INBOX<enter>" "Go to inbox"
macro index,pager gs "<change-folder>=[Gmail]/Starred<enter>" "Go to starred messages"
macro index,pager gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"
macro index,pager e "<enter-command>unset trash\n <delete-message>" "Gmail archive message" # different from Gmail, but wanted to keep "y" to show folders.

Replace the following:

  1. <username>: Your gmail username
  2. <16-character-app-password>: You have to generate this
  3. <name-used-in-the-gmail-account>: Your name as per gmail account

Note: Don't change <change-folder>

Scarron answered 4/12, 2020 at 1:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.