Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change sendmail sender using bash

Tags:

Running the sendmail command I usually get emails with sender like username@hostname.

Is there a way to send emails using sendmail and having the sender set to something different from the user account used to run the command?

like image 404
ztank1013 Avatar asked Sep 15 '11 20:09

ztank1013


People also ask

How do I change sender address in sendmail?

From the sendmail man page: -Ffullname Set the full name of the sender. -fname Sets the name of the ``from'' person (i.e., the sender of the mail). -f can only be used by ``trusted'' users (normally root, daemon, and network) or if the person you are trying to become is the same as the person you are.

How use sendmail command in Linux?

Simple example Once logged in, you can run the following command to send email: [server]$ /usr/sbin/sendmail [email protected] Subject: Test Send Mail Hello World control d (this key combination of control key and d will finish the email.)

How do I change sender in mailx?

You can use the "-r" option to set the sender address: mailx -r [email protected] -s ... This is troubling for me because the man page of mailx says: "-r address Sets the From address. Overrides any from variable specified in environment or startup files.


1 Answers

What you're looking for is -f:

sendmail -F "Your name" -f "[email protected]" < your-message.txt

From the sendmail man page:

 -Ffullname  Set the full name of the sender.

 -fname      Sets the name of the ``from'' person (i.e., the sender of the
             mail).  -f can only be used by ``trusted'' users (normally
             root, daemon, and network) or if the person you are trying to
             become is the same as the person you are.
like image 181
Martin Avatar answered Dec 07 '22 18:12

Martin