-1

I am at my wits end....

All I want to do is set the From using a command line mail in a script.

I have tried mutt, mail, mailx...

Here is on command I tried:

echo "Once again" | mail -s "Maybe this time" -A file.csv stevec@isonas.com -r 'John <john@company.com>' -a From:John\<john@company.com\>

And another:

mutt -e "set from=john@company.com"...

And another:

mutt -e "set from=john@company.com" -e "set realname=John"

My /etc/mailname has the name I want too. I also tried configuring a muttrc file and that doesn't work

And another try:

mailx -r "DoNotReply@company.com" -a "From:DoNotReply@company.com" -s "Subject" -A "/opt/file.csv" "john@anothercompnay.com" <<< Some Text

Any ideas I can try?

1 Answers1

0

I assume that you have configured john@company.com in an extra configuration file (~/.mutt/accounts/john) which you usually source as soon as you start using it in mutt. Simply load that configuration.

echo "mail body" | mutt -e "source ~/.mutt/accounts/john" -e "set content_type=text/plain" -s "subject" -- peter@company.com

An account specific configuration file may look like this (msmtp is used in this case to send mails):

set sendmail        = "/usr/bin/msmtp -a Mailbox"
set realname        = "John"
set from            = "john@company.com"
set mbox_type       = Maildir
set folder          = "/home/john/.mails"
set spoolfile       = "+Mailbox/INBOX"
set record          = "+Mailbox/Sent"
set postponed       = "+Mailbox/Drafts"
ploth
  • 435
  • 8
  • 16