您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Linux上如何给QQ邮箱发邮件?

2024/3/3 12:45:25发布14次查看
公司现在每天生成一些报表,要晚上发人一些员工,因为服务器不支持ssl,重新编译nginx我也不是很懂,生产机弄坏了就完了,所以没法用phpmailer来发, 听说在linux弄个mail服务器,就能通过shell发邮件,求指点
我想做的是,每天晚上6点自动,把生成的文件通过mail的附件,发给email给其他人。
回复内容: 公司现在每天生成一些报表,要晚上发人一些员工,因为服务器不支持ssl,重新编译nginx我也不是很懂,生产机弄坏了就完了,所以没法用phpmailer来发, 听说在linux弄个mail服务器,就能通过shell发邮件,求指点
我想做的是,每天晚上6点自动,把生成的文件通过mail的附件,发给email给其他人。
可以用python来做。
使用smtplib模块。
首先将报表以及需要发送的from ,to信息等编码好。具体可以查看rfc http://tools.ietf.org/html/rfc5321#section-2.3.1
可以给你展示下我写的一个小demo。
pythonimport smtplibdef send_email_over_smtps(to_email,login_user,login_pwd): smtpserver = smtplib.smtp(,587) #此处需要填写服务器地址,587是默认smtps端口 smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(login_user, login_pwd) header = 'to:' + to_email + '\n' + 'from: ' + login_user + '\n' + 'subject:testing \n' print header msg = header + '\n this is test msg from mkyong.com \n\n' smtpserver.sendmail(login_user, to_email, msg) print 'done!' smtpserver.close()if __name__ == __main__: send_email_over_smtps('','','')
每天定时获取到文件,用crontab定时获取,然后组成邮件,发送即可。
在机器b上做个接口,post过去用b机器发邮件。
for the mail functions to be available, php must have access to the sendmail binary on your system
phpmailer也是用的系统函数sendmail
你机器上用不了phpmailer,估计sendmail也是用不了的。别指望用shell发邮件了。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product