Sending a mail from a linux shell script

后端 未结 11 2092
一个人的身影
一个人的身影 2020-12-04 06:52

I want to send an email from a Linux Shell script. What is the standard command to do this and do I need to set up any special server names?

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 07:19

    you can use 'email' or 'emailx' command.

    (1) $ vim /etc/mail.rc # or # vim /etc/nail.rc

    set from = xxx@xxx.com #
    set smtp = smtp.exmail.gmail.com #gmail's smtp server 
    set smtp-auth-user = xxx@xxx.com #sender's email address
    set smtp-auth-password = xxxxxxx #get from gmail, not your email account passwd
    set smtp-auth=login
    

    Because if it is not sent from an authorized account, email will get to junk mail list.

    (2) $ echo "Pls remember to remove unused ons topics!" | mail -s "waste topics" -a a.txt developer@xxx.com #send to group user 'developer@xxxx.com'

提交回复
热议问题