Featured image of post Linux uses mailx to send email

Linux uses mailx to send email

傳電子郵件

mailx [-s subject ] [-r name<from@email.com>] [-a /path/to/file] [-S SMTP ] to@email.com < message.txt

-S smtp="mail.example.com:587"
-S smtp-use-starttls
-S smtp-auth=login
-S smtp-auth-user="user@gmail.com"
-S smtp-auth-password="password"
-S ssl-verify=ignore

使用者登入登出時傳送通知

user@user-pc:~/$ cat ~/.bashrc
# .bashrc
pinky user | mailx -s "Security Alert" -r "user<user@toolman.xyz>" -S "0.0.0.0" user@gmail.com
user@user-pc:~/$ cat ~/.bash_logout
# ~/.bash_logout
echo "User logout!!" | mailx -s "Security Alert" -r "user<user@toolman.xyz>" -S "0.0.0.0" -a ~/.bash_history user@gmail.com

Another method: Use sendmail to send email in Linux  

Licensed under CC BY-NC-SA 4.0