1

I'm using postfix and mail from mailutils to send email using my gmail address through command line in Ubuntu. It works fine when I provide both from and to address like below:

mail -s "Some random subject" -a "From: username@gmail.com" username1@gmail.com

But I need to configure to send email from default gmail address without specifying from address everytime. How can I do that?

Please help me!

dessert
  • 40,956
Harsha
  • 329

2 Answers2

1

You can specify the sender address mail uses by default in your ~/.mailrc file – create it if it doesn't exist yet – with the following line:

set from="username@gmail.com"

If this helps you, please also upvote this answer where I got it from and where you can get a configuration example.

dessert
  • 40,956
0

A general way of adding options you want to be default to a command-line program is an alias, see: How do I create a permanent Bash alias?
In your case this would be a line

alias mail='mail -a "From: username@gmail.com"'

added to either your ~/.bashrc or ~/.bash_aliases file.

dessert
  • 40,956