问题描述
我在Windows 8上安装了WAMP,并尝试使用sendmail发送电子邮件。
代码返回发送电子邮件,但是,测试邮件帐户在其收件箱或垃圾邮件文件夹中未收到任何电子邮件。
I have installed WAMP on windows 8 and am trying to send emails using sendmail.The code returns "email sent", however, the testemail account does not receive any emails in its inbox or spam folder.
这是我的sendmail.ini文件(我已经尝试了25,587,465的smtp_port和ssl,blank,none,tls为smtp_ssl)
This is my sendmail.ini file.(I have tried 25,587,465 for the smtp_port and ssl,blank,none,tls for the smtp_ssl)
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=mypassword
hostname=localhost
这是php.ini文件的[邮件功能]。
This is the [mail function] of the php.ini file.
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP =localhost
; http://php.net/smtp-port
;smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="c:\wamp\sendmail\sendmail.exe -t -i"
这是我发送电子邮件的php文件
And this is my php file for sending emails
<?php
$to = '[email protected]';
$subject='testing';
$message = 'This is a test';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to,$subject,$message,$headers))
{
echo "email sent";
}
else
{
echo "Invalid Email";
}
?>
这是我在调试日志文件中获得的
This is what I am getting in my debug log file
14/11/12 12:25:11 ** --- MESSAGE BEGIN ---
14/11/12 12:25:11 ** To: [email protected]
14/11/12 12:25:11 ** Subject: testing
14/11/12 12:25:11 ** X-PHP-Originating-Script: 0:email.php
14/11/12 12:25:11 ** From: [email protected]
14/11/12 12:25:11 ** Reply-To: [email protected]
14/11/12 12:25:11 ** MIME-Version: 1.0
14/11/12 12:25:11 ** Content-type: text/html; charset=iso-8859-1
14/11/12 12:25:11 ** X-Mailer: PHP/5.3.13
14/11/12 12:25:11 **
14/11/12 12:25:11 ** This is a test
14/11/12 12:25:11 ** --- MESSAGE END ---
14/11/12 12:25:11 ** Connecting to smtp.gmail.com:25
14/11/12 12:25:12 ** Disconnected.
14/11/12 12:25:12 ** Disconnected.
14/11/12 12:25:12 ** Socket Error # 10061<EOL>Connection refused.
我已经尝试使用谷歌搜索解决方案,并设置我的sendmail.exe以管理员权限运行。我也启用了[email protected]上的IMAP访问。任何人都可以帮助我吗?
I have tried googling for the solution and also set my sendmail.exe to run with administrator privileges. I have also enabled IMAP access on [email protected]. Can anyone help me with this?
推荐答案
Google需要身份验证,因此用户名和密码。
Google requires authentication, so username and password. You can see their configuration settings for sendmail here.
配置前面有一个;
分号的任何行都被注释掉,不会被处理。
Any line in the configuration preceded by a ;
semicolon is commented out and will not be processed.
不需要更改服务器超时。在Sendmail中,
服务器超时在Timeout.datafinal值中设置。默认情况下,
设置为一小时。如果Timeout.datafinal值已更改为
较低值,请将该值升高至一小时。
Changing server timeouts should not be necessary. In Sendmail, the server timeout is set in the Timeout.datafinal value. By default, it's set to one hour. If the Timeout.datafinal value has been changed to a lower value, raise the value to one hour.
为Sendmail配置智能主机:
To configure a smarthost for Sendmail:
将以下行添加到/etc/mail/sendmail.mc文件中:
define( SMART_HOST',
smtp-relay.gmail.com')
Add the following line to the /etc/mail/sendmail.mc file: define(SMART_HOST',
smtp-relay.gmail.com')
停止并重新启动sendmail服务器进程。
Stop and restart the sendmail server process.
已完成您的配置,
发送测试消息以确认您的出站邮件正在流动。在
除了上面列出的服务器配置步骤之外,您可能需要
在您的服务器上执行其他配置,如果以下任一
为真:
When you've completed your configuration, send a test message to confirm that your outbound mail is flowing. In addition to the server configuration steps listed above, you may need to perform an additional configuration on your server if either of the following is true:
您单击允许的发件人设置中的任何地址选项,然后单击您不拥有的域(例如yahoo.com)发送邮件的
。您
发送邮件而没有From地址,例如未送达报告或
假期外出通知。在这些情况下,您必须
配置您的邮件服务器以确保服务器正在使用
SMTP AUTH作为注册的应用程序用户进行身份验证,或在HELO中显示一个
的域名或EHLO命令。看到这里的说明
。
You click the Any address option in the Allowed senders setting and you send mail from a domain you do not own, such as yahoo.com. You send mail without a "From" address, such as non-delivery reports or vacation "out of office" notifications. In these cases, you must configure your mail server to either ensure that the server is using SMTP AUTH to authenticate as a registered apps user or to present one of your domain names in the HELO or EHLO command. See the instructions here.
这篇关于使用WAMP和sendmail发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!