Configure mailx in Centos to send emails using external smtp
Configure mailx in Centos to use external smtp to send mail to install mailx
yum install mailx
Configure mailx
I recommend 163 mail, of course, QQ mail is also acceptable, PS: Remember to enter the mailbox to open SMTP
Vi/etc/mail. rc // if it does not exist, edit/etc/nail. rc.
Add the following code at the end of the file. Enter your own account and password for the corresponding account and password.
Set from = "xxx@163.com" set smtp = smtp.163.comset smtp-auth-user = xxxset smtp-auth-password = mailbox password set smtp-auth = login
Use mailx to send emails
The sender name cannot be added. The sender name has been configured in step 2.
If the mail content is stored in the mesg file, you can use the following two methods:
Mailx-s "sender name mail title" xxx@163.com <mesg
Cat mesg | mailx-s "sender name mail title" xxx@163.com
Multiple recipients are separated by commas:
Cat mesg | mailx-s "sender name mail title" xxx@163.com, xxx2@163.com, xxx3@163.com
You can also enter the mail content directly from the command line:
Mailx-s "sender name email title" xxx@163.com # press Ctrl + D after entering
echo hello word | mailx -v -s " title" xxx3@163.com
Pitfall
- Remember to enter the mailbox to open SMTP
- After configuring the proxy, remember to check whether the proxy is enabled (for example, firewall VPN). The proxy may cause Telnet to fail over port 25.