sendmail发邮件由www-data代发 google邮箱当作垃圾邮件 发邮件速度慢

Delivered-To:*****
Received: by 10.194.166.130 with SMTP id zg2csp3430wjb;
        Sat, 11 Jan 2014 01:02:12 -0800 (PST)
X-Received: by 10.68.108.130 with SMTP id hk2mr17360580pbb.16.1389430931370;
        Sat, 11 Jan 2014 01:02:11 -0800 (PST)
Return-Path: <www-data@weibo.yqting.com>
Received: from weibo.yqting.com ([42.121.34.216])
        by mx.google.com with ESMTPS id e8si9658190pac.343.2014.01.11.01.02.00
        for <hnyysly@gmail.com>
        (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sat, 11 Jan 2014 01:02:05 -0800 (PST)
Received-SPF: neutral (google.com: 42.121.34.216 is neither permitted nor denied by best guess record for domain of www-data@weibo.yqting.com) client-ip=42.121.34.216;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 42.121.34.216 is neither permitted nor denied by best guess record for domain of www-data@weibo.yqting.com) smtp.mail=www-data@weibo.yqting.com
Received: from weibo.yqting.com (localhost [127.0.0.1])
	by weibo.yqting.com (8.14.4/8.14.4/Debian-2ubuntu2) with ESMTP id s0B91swR020798
	for <hnyysly@gmail.com>; Sat, 11 Jan 2014 17:01:54 +0800
Received: (from www-data@localhost)
	by weibo.yqting.com (8.14.4/8.14.4/Submit) id s0B91sWh020797;
	Sat, 11 Jan 2014 17:01:54 +0800
 
1.解决由www-data代发的问题
	修改/etc/php5/apachea/php.ini文件
	SMTP = weibo.yqting.com
	smtp_port = 25
	from = service@weibo.yqting.com
	sendmail_from = service@weibo.yqtin.com
	sendmail_path = /usr/sbin/sendmail -t -i -f service@weibo.yqting.com
	修改完以后一定要重启apache。输入命令:service apache2 restart

2.解决当作垃圾邮件和发邮件速度慢的问题
	原来/etc/hosts是	
	127.0.0.1 localhost
	127.0.1.1   ubuntu
	因为sendmail监听的是127.0.0.1,但却无法确认主机名AY121122020321dce8544 (因为在服务器上HOSTNAME是AY121122020321dce8544),所以发送邮件就非常慢了。那么我就把这个主机名同时也加到localhost后面,变成:
 
	修改/etc/hosts
	weibo.yqting.com localhost
	127.0.0.1 weibo.yqting.com localhost AY121122020321dce8544  (ubuntu把主机名添加到这行localhost后面,centos系统添加到上面一行localhost后面)   
	然后重启sendmail服务:service sendmail restart
	
	
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python提供了多个库和模块来实现邮件代发功能,其中比较常用的是smtplib和email库。下面是一个简单的示例代码,演示如何使用Python发送邮件: ```python import smtplib from email.mime.text import MIMEText from email.header import Header # 邮件服务器的地址和端口 smtp_server = 'smtp.example.com' smtp_port = 25 # 发件人和收件人的邮箱地址 sender = 'sender@example.com' receiver = 'receiver@example.com' # 邮件内容 subject = 'Python 邮件代发示例' message = '这是一封使用Python发送邮件。' # 创建邮件对象 msg = MIMEText(message, 'plain', 'utf-8') msg['From'] = Header(sender, 'utf-8') msg['To'] = Header(receiver, 'utf-8') msg['Subject'] = Header(subject, 'utf-8') try: # 连接邮件服务器 server = smtplib.SMTP(smtp_server, smtp_port) # 登录邮箱账号 server.login(sender, 'password') # 发送邮件 server.sendmail(sender, receiver, msg.as_string()) print('邮件发送成功') except Exception as e: print('邮件发送失败:', str(e)) finally: # 关闭连接 server.quit() ``` 在上面的代码中,需要替换以下内容: - `smtp_server`:邮件服务器的地址,例如smtp.gmail.com或smtp.qq.com。 - `smtp_port`:邮件服务器的端口,一般为25或465。 - `sender`:发件人的邮箱地址。 - `receiver`:收件人的邮箱地址。 - `server.login(sender, 'password')`:登录发件人的邮箱账号,需要提供正确的密码。 请注意,为了使用该功能,你需要确保你的发件人邮箱开启了SMTP服务,并且提供了正确的邮箱地址、密码、邮件服务器和端口。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值