Change from email address in mail command

Change from email address in mail command

Using mail command in Linux/Unix to send email, but the sender email address being listed to be coming from something like [email protected]?

Looking for options in the mail command to change this address?

Many of the sites will answer that this won’t be possible in mail command, you need to use sendmail client to send such email(s). I would say otherwise.

You can definitely achieve this by using mail command. In other words, you can change from email address in mail command. Following is the syntax that will do the trick:

Change from email address in mail command

Syntax:

mail -s "My Subject" [email protected] -- -f [email protected]

Example:

[[email protected]]$ mail -s “test mail” [email protected] — -f [email protected]

So in the above example, the mail will be sent to [email protected] but the sender email address will be [email protected] and NOT [email protected]

No Comments

Post a Comment

Time limit is exhausted. Please reload CAPTCHA.