LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   mutt + changing senders email address (https://www.linuxquestions.org/questions/linux-server-73/mutt-changing-senders-email-address-572425/)

aeby 07-26-2007 09:24 AM

mutt + changing senders email address
 
Hi,

I have a cron job that runs a script and emails the result , but the problem is that the sender's email address is root and i want to change it to username@domain.com, i can always set the cron to run as a user but it gives me permission problems . i am using the mutt mail client , i googled around and they asked me to set the options in the .muttrc file but i cannot find that file.
Is there an option on mutt to chane the senders email address?????????????????/

Kind Regards

AlucardZero 07-26-2007 10:12 AM

.muttrc is in the user's home directory. If it's not there, create it.

aeby 07-27-2007 02:39 AM

hi
i have created the .muttrc in roots home directory and gave the option

set from = "xyz@domain.com"

but still when i run mutt it gives me the senders address
as
root<xyz@domain.com>
now what???

Thanks for the reply

aeby 07-27-2007 06:54 AM

hi

to change the from email address while using mutt
create a .muttrc in the users home directory if it doesnot exist, then enter the feild

set realname="username" this will change the name in the senders name .

nkrvivek 05-11-2011 08:27 PM

or you can just simply have an entry

set from="Name <email@example.com>"

in your .muttrc file. No need for an additional realname entry

vikas027 07-20-2011 12:34 PM

This can be done as below -


Code:

export EMAIL=sender@domain && mutt -a /path/to/attachment -s "Subject" ABC@ABC.com < /dev/null

paklan 04-04-2012 04:03 AM

Hello,
I need some help related to this topic if anyone is still monitoring this thread. My problem is similar to this and in googling for information came upon this thread.

I have a shell script that sends a simple email from user root. The aim is to eventually use this mechanism for sending health check information from the machine. The domain the machine resides is not externally known; ie it is on an internal LAN. For example say its hostname is machine1@internal.company.com. Without setting the EMAIL environment variable mutt sends the email to a local SMTPD server for forwarding as root@internal.company.com. This causes the final mail system to reject the mail (rules to stop spamming etc) because it can not resolve the domain internal.company.com.

So in the script I coded 'export EMAIL="myname@realdomain.com"' and when run in the foreground in a bash interactive shell the email is accepted by the final mail system and it is received correctly.
However if I run this same script under CRON it is as though mutt ignores the EMAIL environment variable and sends the email as though it is from root@internal.company.com.

The script looks like this:
export EMAIL="myname@realdomain.com"
EMAILTO="recipient1@otherdomain.com"
SUBJECT="$(hostname) test"
mutt -s "${SUBJECT} ${EMAILTO} </tmp/message.txt

BTW my ~/.muttrc for root looks like this (but does not appear to make any difference if I have the -f or not for sendmail)
set sendmail="/usr/sbin/sendmail -oem -oi -fmyname@realdomain.com"

It appears, to me, that mutt ignores the EMAIL environment variable when it is invoked from a shell that is not interactive. Has anyone else seen this behaviour? Could this be an anti-spamming mechanism?

thanks
Patrick.

diabolusss 11-21-2012 11:20 AM

IF someone is still monitoring
 
Quote:

Originally Posted by paklan
However if I run this same script under CRON it is as though mutt ignores the EMAIL environment variable and sends the email as though it is from root@internal.company.com.

Know nothing about cron, however i noticed that if you set in /etc/Muttrc file these setings:
Code:

set realname="Ashok Kumar"
set from="Ashok.Kumar@unknown.domain"
set use_from=yes

And even if "set use_from" is set to "no" default name will override environment variable, so i commented these lines and everything work fine in script.


All times are GMT -5. The time now is 04:43 AM.