如何使用PHP从本地wamp服务器发送电子邮件?

时间:2021-12-01 18:14:25

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?

我正在使用wamp服务器,我的站点已经加载到我自己的服务器上,请您建议如何使用我的localhost和PHP发送邮件?

5 个解决方案

#1


7  

The mail() function usually doesn't work by default for things like WAMP. You will need to add details of your SMTP server to the php.ini file.

mail()函数通常不会在默认情况下工作,比如WAMP。您将需要向php添加SMTP服务器的详细信息。ini文件。

Here is a nice tutorial: http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

这里有一个不错的教程:http://roshanbh.com.np/2007/12/sending-e-mail from-localhost-in-php-in-windows-environment.html

#2


3  

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.
    • 现在,提取文件夹并将其放到C:/wamp/中。确保有这四个文件:sendmail。exe,libeay32。dll,ssleay32。ddl和sendmail.ini。
    • Open sendmail.ini and set the configuration as follows:

      sendmail开放。ini,设置配置如下:

    • smtp_server=smtp.gmail.com

      smtp_server = smtp.gmail.com

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

      主机名= localhost

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

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

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

      WAMP服务器运行。在Apache模块下启用ssl_module。

    • Next, enable php_openssl and php_sockets under PHP.

      接下来,在PHP中启用php_openssl和php_sockets。

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

      打开php。ini并将其配置为下面的代码。基本上,您只需设置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:\wamp\sendmail\sendmail.exe -t -i"
  • Restart Wamp Server
  • 重启Wamp服务器

I hope this will work for you..

我希望这对你有用。

#3


2  

Open your php.ini and find the [mail function] section

打开你的php。找到[邮件功能]部分

After that you have to change the options that are following and are relevant to your SMTP settings.

之后,您必须更改与SMTP设置相关的后续选项。

Settings to change :

设置变化:

SMTP = ; Enter here the address of your SMTP server
smtp_port = 25

Finaly from with your PHP script you have to use the mail function http://php.net/manual/en/function.mail.php

最后,对于PHP脚本,您必须使用邮件函数http://php.net/manual/en/function.mail.php

#4


0  

You can use the mail function in PHP. http://php.net/manual/en/function.mail.php

您可以在PHP中使用mail函数。http://php.net/manual/en/function.mail.php

As you are hosting it yourself, you have to check your internet provider smtp and update php.ini with it and that should work.

当您自己托管它时,您必须检查您的internet提供者smtp并更新php。有了它,那就行了。

#5


0  

In php.ini, set following parameters:

在php中。ini设置以下参数:

  • SMTP
  • SMTP
  • smtp_port
  • smtp_port
  • sendmail_from
  • sendmail_from
  • sendmail_path
  • sendmail_path

#1


7  

The mail() function usually doesn't work by default for things like WAMP. You will need to add details of your SMTP server to the php.ini file.

mail()函数通常不会在默认情况下工作,比如WAMP。您将需要向php添加SMTP服务器的详细信息。ini文件。

Here is a nice tutorial: http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

这里有一个不错的教程:http://roshanbh.com.np/2007/12/sending-e-mail from-localhost-in-php-in-windows-environment.html

#2


3  

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.
    • 现在,提取文件夹并将其放到C:/wamp/中。确保有这四个文件:sendmail。exe,libeay32。dll,ssleay32。ddl和sendmail.ini。
    • Open sendmail.ini and set the configuration as follows:

      sendmail开放。ini,设置配置如下:

    • smtp_server=smtp.gmail.com

      smtp_server = smtp.gmail.com

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

      主机名= localhost

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

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

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

      WAMP服务器运行。在Apache模块下启用ssl_module。

    • Next, enable php_openssl and php_sockets under PHP.

      接下来,在PHP中启用php_openssl和php_sockets。

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

      打开php。ini并将其配置为下面的代码。基本上,您只需设置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:\wamp\sendmail\sendmail.exe -t -i"
  • Restart Wamp Server
  • 重启Wamp服务器

I hope this will work for you..

我希望这对你有用。

#3


2  

Open your php.ini and find the [mail function] section

打开你的php。找到[邮件功能]部分

After that you have to change the options that are following and are relevant to your SMTP settings.

之后,您必须更改与SMTP设置相关的后续选项。

Settings to change :

设置变化:

SMTP = ; Enter here the address of your SMTP server
smtp_port = 25

Finaly from with your PHP script you have to use the mail function http://php.net/manual/en/function.mail.php

最后,对于PHP脚本,您必须使用邮件函数http://php.net/manual/en/function.mail.php

#4


0  

You can use the mail function in PHP. http://php.net/manual/en/function.mail.php

您可以在PHP中使用mail函数。http://php.net/manual/en/function.mail.php

As you are hosting it yourself, you have to check your internet provider smtp and update php.ini with it and that should work.

当您自己托管它时,您必须检查您的internet提供者smtp并更新php。有了它,那就行了。

#5


0  

In php.ini, set following parameters:

在php中。ini设置以下参数:

  • SMTP
  • SMTP
  • smtp_port
  • smtp_port
  • sendmail_from
  • sendmail_from
  • sendmail_path
  • sendmail_path