如何使用 PHP 从本地 wamp 服务器发送电子邮件? [英] How to send email from local wamp server using PHP?

查看:42
本文介绍了如何使用 PHP 从本地 wamp 服务器发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我的本地主机发送电子邮件.

我正在使用 wamp 服务器并且我的站点加载在我自己的服务器上,请您建议如何使用我的本地主机和 PHP 发送电子邮件?

解决方案

以下是实现此目标的步骤:

  • 通过这个链接

    • 现在,解压缩文件夹并将其放入 C:/wamp/.确保存在以下四个文件:sendmail.exe、libeay32.dll、ssleay32.ddl 和 sendmail.ini.
    • 打开sendmail.ini,设置如下配置:

    • smtp_server=smtp.gmail.com

    • smtp_port=465
    • smtp_ssl=ssl
    • default_domain=localhost
    • error_logfile=error.log
    • debug_logfile=debug.log
    • auth_username=[your_gmail_account_username]@gmail.com
    • auth_password=[your_gmail_account_password]
    • pop3_server=
    • pop3_username=
    • pop3_password=
    • force_sender=
    • force_recipient=
    • 主机名=本地主机

    • 访问您的电子邮件帐户.单击齿轮工具 > 设置 > 转发和 POP/IMAP > IMAP 访问.点击启用 IMAP",然后保存您的更改.

    • 运行您的 WAMP 服务器.在Apache Module下启用ssl_module.

    • 接下来,在PHP下启用php_openssl和php_sockets.

    • 打开php.ini,配置如下代码.基本上,您只需要设置 sendmail_path.

<块引用>

【邮件功能】;仅适用于 Win32.;http://php.net/smtp;SMTP =;http://php.net/smtp-port;smtp_port = 25;仅适用于 Win32.;http://php.net/sendmail-from;sendmail_from = you@domain.com;仅适用于 Unix.您也可以提供参数(默认值:sendmail -t -i").;http://php.net/sendmail-pathsendmail_path = "C:wampsendmailsendmail.exe -t -i"

  • 重启 Wamp 服务器

我希望这对你有用..

I need to send email messages from my localhost.

I am using wamp server and my site is loaded on my own server, please could you suggest how to send emails using my localhost and PHP?

解决方案

Here's the steps to achieve this:

  • Download the sendmail.zip through this link

    • Now, extract the folder and put it to C:/wamp/. Make sure that these four files are present: sendmail.exe, libeay32.dll, ssleay32.ddl and sendmail.ini.
    • Open sendmail.ini and set the configuration as follows:

    • smtp_server=smtp.gmail.com

    • smtp_port=465
    • smtp_ssl=ssl
    • default_domain=localhost
    • error_logfile=error.log
    • debug_logfile=debug.log
    • auth_username=[your_gmail_account_username]@gmail.com
    • auth_password=[your_gmail_account_password]
    • pop3_server=
    • pop3_username=
    • pop3_password=
    • force_sender=
    • force_recipient=
    • hostname=localhost

    • Access your email account. Click the Gear Tool > Settings > Forwarding and POP/IMAP > IMAP access. Click "Enable IMAP", then save your changes.

    • Run your WAMP Server. Enable ssl_module under Apache Module.

    • Next, enable php_openssl and php_sockets under PHP.

    • Open php.ini and configure it as the codes below. Basically, you just have to set the sendmail_path.

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP =
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = you@domain.com
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:wampsendmailsendmail.exe -t -i"

  • Restart Wamp Server

I hope this will work for you..

这篇关于如何使用 PHP 从本地 wamp 服务器发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆