【问题标题】:Sending email from localhost is not working从本地主机发送电子邮件不起作用
【发布时间】:2014-05-17 11:13:50
【问题描述】:

一年前,我尝试启用从 WAMP 作为 localhost 发送电子邮件但失败了。我只是再次齐心协力,但又失败了。这就是我所做的,希望有人能帮帮我。

由于 WAMP 不附带 sendmail.exe,因此创建了一个文件夹 c:\wamp\sendmail,并将 DIR 中所示的以下文件复制到其中:

Directory of c:\WAMP\sendmail
14-01-11  03:44 PM         1,112,064 libeay32.dll
18-06-11  01:10 AM           932,864 sendmail.exe
04-04-14  10:45 PM             2,123 sendmail.ini
14-01-11  03:44 PM           275,968 ssleay32.dll

此文件夹中的sendmail.ini设置如下,关键行为5(smtp_serversmtp_portdefault_domainauth_usernameauth_password):

smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=587
smtp_ssl=auto

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=localhost

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

;debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=mynamegmail.com
auth_password=mypassword

c:\WAMP\bin\php\php5.4.3php.iniphp.ini中,修改了一行,即 sendmail_path ="\"c:\Wamp\sendmail\sendmail.exe\" -t"

接下来在C:\wamp\www 中创建一个sendmail.php 文件,其内容如下:

<?php
mail('receipient@yahoo.com','sample mail','sample content','From: sender@gmail.com');
?>

在运行 localhost 的网络浏览器中,`sendmail.phpv 已运行,但邮件未通过。

  • 为什么本地主机没有按照sendmail.php的指示发送邮件?
  • 有什么遗漏或错误吗?
  • sendmail.exe 加上其他.dll 错了吗?
  • php.inisendmail.inisendmail.php中的条目错了吗?

【问题讨论】:

标签: php email sendmail.exe


【解决方案1】:

发送邮件.ini

[发送邮件]

smtp_server=smtp.gmail.com

smtp_port=465

smtp_ssl=ssl

error_logfile=error.log

debug_logfile=debug.log

auth_username=[email]@gmail.com

auth_password=[电子邮件密码]

pop3_server=

pop3_username=

pop3_password=

force_sender=[email]@gmail.com

force_recipient=主机名=smtp.gmail.com

php.ini

[邮件功能]

SMTP = smtp.gmail.com

smtp_port = 465

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

mail.add_x_header=关闭

【讨论】:

    猜你喜欢
    • 2016-07-22
    • 1970-01-01
    • 2013-04-16
    • 2014-10-25
    • 2013-10-01
    • 2010-12-19
    相关资源
    最近更新 更多