Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to send mail by shell in linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the linux shell how to send mail, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Start:

Because I have written many paths here, it is best to install them according to my installation path. Or modify the path according to your own environment. Pay attention to the comments below.

Because of this I have written into a sh file, as long as the implementation of install.sh can, but here can not send attachments, I will open it to write it, notice that there are 2 hidden files.

I use 163 free mail. If you use something else, change the corresponding smtp address. The following comments do not need to be copied.

The code is as follows:

Mkdir-p / usr/local/msmtp/etc

Vi / root/.msmtprc / / Note that the file name is preceded by a "dot"

Host smtp.163.com / / smtp address

Tls off

Auth plain

From meiti_jiankong@163.com / / which email is it from?

User meiti_jiankong / / user name

Password a # ^ * 225*mgYjm21 / / email password

Vi / root/.muttrc

The location where set sendmail= "/ usr/local/msmtp/bin/msmtp" / / msmtp is installed. Change according to one's own situation

Set use_from=yes

Set from=meiti_jiankong@163.com / / user name

Set envelope_from=yes

Vi / usr/local/msmtp/etc/msmtprc

Defaults

Account meiti_jiankong / / user name

Host smtp.163.com / / smtp-IP

From meiti_jiankong@163.com / / user name

Auth login

Port 25

Tls off

User meiti_jiankong@163.com / / user name

Password a # ^ * 225*mgYjm21 / / password

Account default: meiti_jiankong

Logfile / usr/local/msmtp/log/msmtp.log / / user name

The above three files are saved in this way, please make sure that the user name, password and stmp are correct. One more time:

Mkdir-p / usr/local/msmtp/log

Echo 'set sendmail= "/ usr/local/msmtp/bin/msmtp" > / etc/Muttrc

Echo "set use_from=yes" > > / etc/Muttrc

Echo 'set realname= "meiti_jiankong@163.com" > / etc/Muttrc / / change this to your own mailbox

Echo 'set editor= "vim" > / etc/Muttrc

Install the package msmtp

Tar jxvf msmtp-1.4.21.tar.bz2

Cd msmtp-1.4.21

. / configure-- prefix=/usr/local/msmtp

Make

Sleep 3

Make install

Sleep 3

Cd..

Tar zxvf mutt-1.5.21.tar.gz

Cd mutt-1.5.21

. / configure-- prefix=/usr/local/mutt

Make

Sleep 3

Make install

Sleep 3

Cd..

Ln-s / usr/local/msmtp/bin/msmtp / usr/bin

So it's done.

Send a command:

/ usr/local/mutt/bin/mutt-s "message title" 281450202@qq.com-c 1516070****@139.com

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report