【问题标题】:Setting up email with wamp使用 wamp 设置电子邮件
【发布时间】:2014-03-11 11:14:51
【问题描述】:

我见过很多网站模板都有基于 AJAX 的联系表单,当您单击提交发送消息时,他们说它实际上并没有发送邮件, 我想用我正在构建的模板来实现这个系统。

我已经安装了 wamp,模板和 php 文件也准备好了,我不知道下一步该做什么。 php文件:http://pastebin.com/YGGK7xsH

javascript 文件:http://pastebin.com/RM2TNFNX

【问题讨论】:

  • 将其更改为$("#feedbackSubmit").click(function(e) { e.preventDefault();,此外,除非您提供了一些无法正常工作的代码,或者您的问题可能无法回答。
  • 可以在 WAMP 上完成,您只需在其中输入 SMTP 信息

标签: javascript php html wamp


【解决方案1】:

您不能使用 WAMPP 发送邮件,因为它是本地服务器。

查看此帖子以获取更多信息和解决方案: Send email from localhost running XAMMP in PHP using GMAIL mail server

【讨论】:

  • 发送邮件是一个 zip 文件,我应该将它们解压到哪里?
【解决方案2】:

使用 sendmail 从 localhost/WAMP 服务器发送电子邮件

此解决方案需要 sendmail.exe(一个命令行界面 (CLI) 可执行文件,它接受来自 PHP 的电子邮件,连接到 SMTP 服务器并发送电子邮件)。你不需要通过命令来使用它,不用担心它:-) Download the sendmail.zip 并按照以下步骤操作:

Create a folder named “sendmail” in “C:\wamp\”.
    Extract these 4 files in “sendmail” folder: “sendmail.exe”, “libeay32.dll”, “ssleay32.dll” and “sendmail.ini”.
    Open the “sendmail.ini” file and configure it as following
        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

您不需要为这些属性指定任何值:pop3_server、pop3_username、pop3_password、force_sender、force_recipient。如果您已经发送成功的电子邮件,则 error_logfile 和 debug_logfile 设置应保持空白,否则此文件的大小将不断增加。如果您无法使用 sendmail 发送电子邮件,请启用这些日志文件设置。

在您的 GMail 设置 -> 转发和 POP/IMAP -> IMAP 访问中启用 IMAP 访问

在 Apache 服务器中启用“ssl_module”模块

为 PHP 编译器启用“php_openssl”和“php_sockets”扩展

从“C:\wamp\bin\apache\Apache2.2.17\bin”打开php.ini,配置如下 (“C:\wamp\bin\php\php5.3.x”中的 php.ini 不起作用) (您只需要在下面的代码中配置最后一行,在其他行前面加上分号(;)

[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"

重新启动 WAMP 服务器。

创建一个 PHP 文件并在其中写入以下代码:

<?php
$to       = 'recipient@yahoo.com';
$subject  = 'Testing sendmail.exe';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: sender@gmail.com' . "\r\n" .
            'Reply-To: sender@gmail.com' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
    echo "Email sent";
else
    echo "Email sending failed";
?>

对 $to 和 $headers 变量进行适当的更改以设置收件人、发件人和回复地址。将其保存为“send-mail.php”。 (您可以将其保存在“C:\wamp\www”中的任何位置或任何子文件夹中。) 在浏览器中打开此文件,它现在必须工作

参考链接http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/

【讨论】:

  • 现在一切正常,但是当我检查我的电子邮件时,里面没有任何消息。我相信你们可以帮助我。谢谢
  • 请检查垃圾邮件并手动确认 php.ini 和 httpd.conf 文件中的所有设置。因为有时服务显示在 wamp 中启用,但如果您打开配置文件则显示未启用
猜你喜欢
  • 2010-12-31
  • 2011-06-16
  • 2014-05-20
  • 1970-01-01
  • 1970-01-01
  • 2010-10-10
  • 1970-01-01
  • 2013-11-23
  • 1970-01-01
相关资源
最近更新 更多