Easy Tutorial
❮ Verilog Process Structure Verilog Numerical Conversion ❯

Sending Emails Using Commands in Linux

Category Programming Technology

When managing servers, we often need to write monitoring scripts and then notify via email when issues arise. Next, we will introduce the simplest way to send emails in Linux:


Centos, RedHat System mail Command

1. Turn off the sendmail service or postfix service on your local machine

# Execute the following commands, everyone find their place
# sendmail
service sendmail stop
chkconfig sendmail off
# postfix
service postfix stop
chkconfig postfix off

# If you want to go further, just uninstall them..
yum remove sendmail
yum remove postfix

2. Then modify /etc/mail.rc, add the following content at the end of the file to specify the external smtp server address, account, and password

$ vi /etc/mail.rc  
set [email protected]
set smtp=smtp.qq.com  
set smtp-auth-user=123456
set smtp-auth-password=tutorialpro
set smtp-auth=login

Here, the QQ Mail SMTP is used, which requires the following configuration:

QQ Mail sets a password by generating an authorization code:

3. Then send an email via command

echo hello word | mail -s "title" [email protected]

Ubuntu System heirloom-mailx Command

1. Install heirloom-mailx

sudo apt-get install heirloom-mailx

2. Configuration

vi /etc/nail.rc Add the authenticated smtp server required by QQ Mail:

set [email protected]
set smtp=smtp.qq.com
set [email protected]
set smtp-auth-password=tutorialpro
set smtp-auth=login

3. Send an email to a QQ Mail user from the command line

echo "Email content" | heirloom-mailx -s "Email title" [email protected]

** Click to Share Notes

Cancel

-

-

-

❮ Verilog Process Structure Verilog Numerical Conversion ❯