【问题标题】:php mail using sendmail.exe使用 sendmail.exe 的 php 邮件
【发布时间】:2010-10-23 09:13:27
【问题描述】:

我在本地主机窗口上使用XAMPP VISTA m/c...使用 gmail 作为 smpt 服务器

我正在尝试使用简单的 PHP 脚本发送电子邮件

这是sendmail.ini 的配置详细信息(我在该目录中有sendmail.exe 和另外2 个dll)

smtp_server=smtp.gmail.com
; smtp port (normally 25)

smtp_port=465

; 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=xxxxxxx
auth_password=xxxxxx

hostname=localhost

and I have changed the php.ini

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = xxxxx

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

一旦我调用脚本,它就会进入等待...等待本地主机... 这是 debug.log...

09/05/02 17:34:41 ** --- 消息开始 --- 2002 年 9 月 5 日 17:34:41 ** 至:xxx@yahoo.com 09/05/02 17:34:41 ** 主题:表格提交结果 09/05/02 17:34:41 ** 来自:我的网站 09/05/02 17:34:41 ** 回复:xxx@gmail.com 2002 年 9 月 5 日 17:34:41 ** 09/05/02 17:34:41 ** 姓名:xxx 2002 年 9 月 5 日 17:34:41 ** 电子邮件:xxx@yahoo.com 09/05/02 17:34:41 ** 消息:嘿测试消息 2002 年 9 月 5 日 17:34:41 ** 2002 年 9 月 5 日 17:34:41 ** 09/05/02 17:34:41 ** --- 消息结束 --- 09/05/02 17:34:41 ** 连接到 smtp.gmail.com:465 2002 年 9 月 5 日 17:34:41 ** 已连接。

我是PHP 的新手,想知道是否有更好的邮件发送方式...我现在不接受带有附件的 HTML/多部分邮件... 此外,我应该能够在没有安装 SMTP 服务器的情况下在 localhost 中进行测试。我现在想使用GMAIL 进行测试。 谢谢

【问题讨论】:

    标签: php email sendmail.exe


    【解决方案1】:

    GMAIL 需要 SSL afaik。

    我知道Zend_MailSwiftmailer 的免费(可能是“好”)php 邮件库。

    【讨论】:

      【解决方案2】:

      您还应该咨询您的 ISP。他们中的许多人阻止了端口 25 以防止垃圾邮件。

      【讨论】:

        【解决方案3】:

        我强烈建议您使用库,例如PHPMailer。这是他们的gmail example

        另一个好的库(我没用过)是SwiftMailer。这是他们的gmail example

        【讨论】:

          【解决方案4】:

          发送电子邮件 - GMAIL

          1) 停止服务器。

          2) 改变这一行

          [XAMPP -> PHP -> php.ini]

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

          [XAMPP -> SENDEMAIL ->sendmail.ini]

          smtp_port=587 
          auth_username= xxxx@gmail.com 
          auth_password= xxxx 
          smtp_ssl=auto
          

          3) 运行服务器

          4) 发送邮件测试

          <?php $to      = 'youremail@xxxx.com'; $subject = 'Test Email
           Email'; $message = 'Hello'; $headers = 'From:
           test@test.com' . "\r\n" .
               'Reply-To: test@test.com' . "\r\n" .
               'X-Mailer: PHP/' . phpversion();
          
           echo print_r(mail($to, $subject, $message, $headers),true); ?>
          

          【讨论】:

            猜你喜欢
            • 2011-12-08
            • 2014-08-22
            • 2018-02-05
            • 2010-09-07
            • 1970-01-01
            • 1970-01-01
            • 2019-02-04
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多