Featured image of post Linux uses mailx to send email

Linux uses mailx to send email


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

-S smtp="mail.example.com:587"
-S smtp-use-starttls
-S smtp-auth=login
-S smtp-auth-user="[email protected]"
-S smtp-auth-password="password"
-S ssl-verify=ignore


user@user-pc:~/$ cat ~/.bashrc
# .bashrc
pinky user | mailx -s "Security Alert" -r "user<[email protected]>" -S "" [email protected]
user@user-pc:~/$ cat ~/.bash_logout
# ~/.bash_logout
echo "User logout!!" | mailx -s "Security Alert" -r "user<[email protected]>" -S "" -a ~/.bash_history [email protected]

Another method: Use sendmail to send email in Linux  

Licensed under CC BY-NC-SA 4.0