Friday, April 7, 2017

Issue mail messages from Debian/Ubuntu command line


This is accomplished by using the ssmtp package of Linux system.

1. install smtp package for the linux system:
sudo apt update
sudo apt install mailutils
sudo apt install ssmtp
sudo apt install postfix

2. edit the /etc/ssmtp/ssmtp.conf file, an example of ssmtp.conf file should be seen like this:
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=i2r.nbt.linux@gmail.com
# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
rewriteDomain=gmail.com
# The full hostname
hostname=gmail.com
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=i2r.nbt.linux
AuthPass=neuroi2r
AuthMethod=LOGIN
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

3. Test the smtp mail service.

echo "Test mail" | mail -v -s "Testing" huangs@i2r.a-star.edu.sg

Sometime the gmail account need to change the setting, namely the security of mail account.
This procedure works for gmail. But for office 365, initial testing failed. May need to change setting but no chance to do it.

No comments:

Post a Comment

NYSE:ORCL -- Oracle

26-03-11 ☁️ Oracle:杠杆的艺术 2026财年第三季度关键指标: ☁️营收增长加速(但存在一些问题):总营收达到 172 亿美元,同比增长 22%。按固定汇率计算,增长率仅为 18%,这意味着部分增长来自汇率波动,而非实际需求。 📦 积压订单持续攀升:RPO 达...