shell 发送邮件

bin/mail(bin/mailx)默认使用本地sendmail发送邮件,本地的机器必须安装并启动Sendmail服务,配置比较麻烦,不稳定。

下文通过修改配置文件可以使用外部SMTP服务器来发送邮件。

以网易邮箱为例。

1、vim  /etc/mail.rc #( /etc/nail.rc),追加如下文字

set [email protected]

set smtp=smtp.163.com

set [email protected]

set smtp-auth-password=aaaa

set smtp-auth=login

说明:

from是发送的邮件地址

smtp是发生的外部smtp服务器的地址

smtp-auth-user是外部smtp服务器认证的用户名

smtp-auth-password是外部smtp服务器认证的用户密码

smtp-auth是邮件认证的方式

配置后执行如下命令:

cat context.txt| mail -s "tes the smtp mail" [email protected]

[email protected]是收件人地址,content.txt里面是邮件正文.

时间: 2024-08-02 07:05:37

shell 发送邮件的相关文章

linux下msmtp+mutt+shell发送邮件

Linux下安装配置msmtp和mutt发送邮件 作者: 纵横域内 日期: 2014 年 12 月 11 日发表评论 (0)查看评论 Linux下安装配置msmtp和mutt Linux下有发送邮件的需求,mail搞不定,因为很多邮件服务器屏蔽了mail发送的请求(明显嘛,都木有发送源-_-).在网上搜了一把,使用msmtp+mutt可以搞定,记录如下. 一.安装配置msmtp1.下载.解压 msmtpwget http://downloads.sourceforge.net/msmtp/msm

shell发送邮件函数

#发送邮件函数 function send_mail(){ #定义邮件发送列表 maillist=( [email protected] [email protected] [email protected] ) if [ "$1" == "gateway" ];then         for mail in ${maillist[*]};do                 echo "无法ping通网关,请检查网络" | mail -s &

shell发送邮件

echo "$IP is down" | mail -s "warn!server: $IP not't restart" [email protected]

linux下shell发送邮件方法

首先需要安装mutt和msmtp sudo apt-get install mutt sudo apt-get install msmtp 编辑mutt配置文件系统全局设置/etc/Muttrc,如果使用某个系统用户,可以在~/.muttrc中设置.vim .muttrcset sendmail="/usr/bin/msmtp"set use_from=yesset realname="123"              set [email protected] 

再谈用java实现Smtp发送邮件之Socket编程

很多其它内容欢迎訪问个人站点   http://icodeyou.com 前几天利用Socket实现了用java语言搭建webserver,全程下来应该会对Socket这个东西已经使用的很熟悉了.尽管抽象,可是使用过一次之后就会感受到它在网络通信上的作用是多么的强大.正好,今天就继续用Socket来练习使用下面Smtp协议发送一封简单的电子邮件.今天的故事呢,是我要约我女神出去吃饭啦啦啦~~~所以,面对Smtp.仅仅许成功,不许失败. 全局假定我的邮箱为[email protected]   女

【简说Python WEB】flask-mail电子邮件

目录 flask-mail flask shell发送邮件 系统环境:Ubuntu 18.04.1 LTS Python使用的是虚拟环境:virutalenv Python的版本:Python 3.6.9 flask-mail 1.安装flask-mail pip install flask-mail 2.配置flask-mail使用qq邮箱 flask-mail STMP服务器的配置 配置 默认值 说明 MAIL_SERVER localhost smtp电子邮件服务器的主机名或IP地址 MA

用shell脚本监控linux系统 自动发送邮件

此脚本可以做一个定时的检测,超出设定的值,即往邮箱发送警告 脚本用到bc,sendmail,163邮箱, yum install bc #!/bin/bash #System Monitoring Script while [ 1 ] do #本机需开启postfix或sendmail服务. #报警邮件地址设置 [email protected] [email protected] #设置脚本运行间隔时间.单位(秒). RUNTIME=900 #内存使用率监控设置,单位 (%) MEMTHRE=

shell 脚本获取远程服务器信息并发送邮件

1 [[email protected] expect]# cat ssh_dsa.exp 2 #!/usr/bin/expect 3 set ip [lindex $argv 0] 4 set pass [lindex $argv 1] 5 set port [lindex $argv 2] 6 set user [lindex $argv 3] 7 set id_dsa [lindex $argv 4] 8 9 if { $id_dsa == "1" } {set id "

shell脚本编写监控内存并发送邮件

1.准备发送邮件的工具: #!/usr/bin/python# -*- coding: UTF-8 -*-import sysimport smtplibimport email.mime.multipartimport email.mime.text server = 'smtp.163.com'port = '25' def sendmail(server,port,user,pwd,msg): smtp = smtplib.SMTP() smtp.connect(server,port)