Linux发送邮件使用外部邮箱

一般Linux发送报警邮件通过本地邮箱或外部邮箱服务器,我习惯使用本地邮箱发邮件,装个Sendmail安装启动,即可实现发送邮件功能,但会存在两个问题:

1、发件人默认显示主机名,有的会被邮件服务商当垃圾邮件处理,也可以使用mutt定义发件人解决这个问题,要麻烦一下。

2、发件延迟,正常的话,一分钟之内可以收到,延迟大的话,几个小时收不到也很正常,这样一来运维工程师没有及时收到告警邮件,耽误问题处理及时性。

针对这两个问题,用外部邮箱就可以解决,你只需简单注册个国内的邮件服务商邮箱,如163,也可以使用公司邮箱,需要安装mailx工具,mailx是一个小型的邮件发送程序,安装很简单,如下:

CentOS:

# yum install mailx

# vi /etc/mail.rc     #添加邮件信息

set [email protected] smtp=smtp.163.com

set [email protected] smtp-auth-password=123456

set smtp-auth=login

Ubuntu:

# sudo apt-get install heirloom-mailx

# vi /etc/nail.rc     #注意文件名和CentOS不同

set [email protected] smtp=smtp.163.com

set [email protected] smtp-auth-password=123456

set smtp-auth=login

发送邮件测试:

# echo "this is test mail." |mail -s "test mail" [email protected]

提示:如果是QQ邮箱,要设置邮箱开启客户端连接支持,设置-->账户-->开启POP3/SMTP服务

时间: 2024-08-10 23:14:52

Linux发送邮件使用外部邮箱的相关文章

linux mail利用外部邮箱地址发邮件

mail命令发送邮件需要sendmail或postfix服务 三种常用格式发信 mail -s "标题" [email protected] #第一种方法,你可以把当前shell当成编辑器来用,编辑完内容后Ctrl-D结束 echo “mail content”|mail -s "标题" [email protected] #第二种方法,我用的最多,可能是喜欢管道的缘故吧 mail -s "标题" [email protected] < f

Linux SendMail 使用外部SMTP服务发送邮件

前言 现在sendmail服务是Linux系统自带服务,默认可能没有启动. 本文不是讲解如何搭建本地mail服务器,而仅仅是作为客户端,使用外部smtp服务发送邮件,因此无需启动sendmail服务. 学习笔记,以备查阅. 1.Sendmail配置 配置发生邮件的邮箱认证信息 vi /etc/mail.rc --- 增加如下内容 --- 1 set [email protected] 2 set smtp=mail.your-domain.com 3 set smtp-auth-user=you

Linux 通过sendmail 发邮件到外部邮箱

Linux 通过sendmail 发邮件到外部邮箱 最近在写自动化巡检脚本,想着怎么预警后自动发送邮件报警. 首先下载最新版本mailx-12.4.tar.bz2 # wget http://sourceforge.net/projects/heirloom/files/latest/download?source=files 解压包: # tar jxvf mailx-12.4.tar.bz2 # cd mailx-12.4 # make # make install UCBINSTALL=/

Zabbix使用外部邮箱服务器发送邮件报警

zabbix服务端配置: 操作系统:CentOS7_x64 1.  安装一个邮件发送程序mailx工具 [[email protected] ~]# yum install mailx -y 打开mailx配置文件,在末尾添加如下信息: [[email protected] ~]# vi /etc/mail.rc set [email protected] smtp=smtp.163.com [email protected] smtp-auth-password=123456 set smtp

linux发送邮件指定发件人

一般使用mail命令发送邮件时,默认发件人为本地用户root或其他 通过修改/etc/mail.rc文件来指定email发件人 使用外部SMTP服务器(163.126等)来发送邮件; 在/etc/mail.rc文件中添加发件人的邮箱认证信息: vi /etc/mail.rc set [email protected] set smtp=smtp.163.comset smtp-auth-user=zrer90set smtp-auth-password=passwdset smtp-auth=l

sendmail设置外部邮箱

1.设置邮箱的客户端授权码 2.开启smtp服务 3.安装sendmail [[email protected]:~]# yum -y install sendmail 配置mail.rc,添加下面的信息 [[email protected]:~]# vi /etc/mail.rc -- set [email protected]        #外部发送邮箱地址 set smtp=smtp.163.com   #外部smtp服务器地址 set smtp-auth-user=nideyouxia

开机启动+Linux发送邮件

需求:检测Linux上Tomcat是否允许,挂了的话给运维发送邮件通知 实现:编写脚本一直检测Tomcat进程是否存活,否则给运维发送邮件,脚本设置开机时自动启动 1.Linux发送邮件 vim /etc/mail.rc 添加如下配置 set from=[email protected] set smtp=smtp.yeah.net set smtp-auth-user=[email protected] set smtp-auth-password=passwordxxx set smtp-a

c++使用stmp协议发送邮件(163的邮箱,TTL非SSL)

0.有关TLS和SSL SSL/TLS是用来加密邮件流的.如果不加密的话很容易被人破解. 不过既然是要发送广告邮件,这个就不用在意了,使用没加密的就行. 另外在使用的时候,发现,qq的邮箱需要使用SSL才能连接上,这个再以后需要用qq发群邮件的时候再来处理,这里暂时只是使用163的邮箱,作为发送端 1.主要的类 SendMail.h: /*********************************************************************** *发送邮件模块头

编写脚本:访问一网站,每5分钟访问一次,如果访问成功,将访问记录保存到日志,如果访问失败,则发送邮件至指定邮箱

今天由于业务需求,要把检查公司的网站是否能被外网访问到,就在同事的指导下做一个计划任务,首先得了解需求: 每五分钟访问公司网站一次,如果访问成功,将访问记录保存到日志,如果访问失败,就发送邮件到指定邮箱中. 需求拿到了,怎么去实现呢? 怎么去实现这个功能,在下愚钝,没有多想,肯定是crontab这个功能,于是直接就写出一个脚本(水平仅限于今天上午),脚本如下: [email protected] */5 * * * * curl http://www.baidu.com 这个肯定不行,最后我询问