使用sendmail.exe发送php邮件
我在本地主机 Windows VISTA
m/c 上使用 XAMPP
...使用 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"
,一旦我调用脚本,它就会进入等待...本地主机。 .. 这是调试日志...
09/05/02 17:34:41 ** --- 消息开始 --- 09/05/02 17:34:41 ** 致:[电子邮件受保护] 09/05/02 17:34:41 ** 主题:表格提交结果 09/05/02 17:34:41 ** 来自:我的网站 09/05/02 17:34:41 ** 回复:[电子邮件受保护] 2002 年 9 月 5 日 17:34:41 ** 2002 年 9 月 5 日 17:34:41 ** 姓名:xxx 09/05/02 17:34:41 ** 电子邮件:[电子邮件受保护] 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 09/05/02 17:34:41 ** 已连接。
我是 PHP
的新手,想知道是否有更好的方法来处理邮件...我现在不喜欢带有附件的 HTML/多部分邮件... 另外,我应该能够在没有安装 SMTP 服务器的情况下在本地主机中进行测试。 我现在想使用 GMAIL
进行测试。 想法
I am using XAMPP
on a localhost windows VISTA
m/c...using gmail as smpt server
I am trying to send an email using simple PHP script
here is the configuration details on sendmail.ini
(I have the sendmail.exe
and the other 2 dll in that directory)
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"
and Once I call the script it goes into waiting...for localhost...
here is the debug.log...
09/05/02 17:34:41 ** --- MESSAGE BEGIN ---
09/05/02 17:34:41 ** To: [email protected]
09/05/02 17:34:41 ** Subject: Form Submission Results
09/05/02 17:34:41 ** From: My Web Site
09/05/02 17:34:41 ** Reply-To: [email protected]
09/05/02 17:34:41 **
09/05/02 17:34:41 ** Name: xxx
09/05/02 17:34:41 ** E-Mail: [email protected]
09/05/02 17:34:41 ** Message: hey test message
09/05/02 17:34:41 **
09/05/02 17:34:41 **
09/05/02 17:34:41 ** --- MESSAGE END ---
09/05/02 17:34:41 ** Connecting to smtp.gmail.com:465
09/05/02 17:34:41 ** Connected.
I am new to PHP
and would like to know if there is a better way to do mail...I am not in for HTML/multipart mails with attachment now...
Also i should be able to test in localhost without SMTP
server installed . I would like to use GMAIL
for now testing.
THnks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我强烈建议您使用一个库,例如 PHPMailer。 这是他们的 gmail 示例。
另一个好的库(我没有使用过)是 SwiftMailer。 这是他们的 gmail 示例。
I strongly suggest you use a library e.g. PHPMailer. Here is their gmail example.
Another good library (which I haven't used) is SwiftMailer. Here is their gmail example.
据我所知,GMAIL 需要 SSL。
我知道的免费(可能是“好”)php邮件库 Zend_Mail 和 Swiftmailer。
GMAIL needs SSL afaik.
Of free (and probably "good") php mail libraries i know Zend_Mail and Swiftmailer.
您还应该咨询您的 ISP。 其中很多会阻止端口 25 以防止垃圾邮件。
You should also check with your ISP. A lot of them block port 25 to prevent spam.
发送电子邮件 - GMAIL
1) 停止服务器。
2) 更改此行
[XAMPP -> PHP-> php.ini]
[XAMPP -> SENDEMAIL ->sendmail.ini]
3) 运行服务器
4) 发送电子邮件测试
Send Email - GMAIL
1) Stop Server.
2) Change this lines
[XAMPP -> PHP -> php.ini]
[XAMPP -> SENDEMAIL ->sendmail.ini]
3) Run Server
4) Send email test