(WAMP/XAMP)使用SMTP本地主机发送邮件

(WAMP/XAMP)使用SMTP本地主机发送邮件,smtp,Smtp,如何从本地主机SMTP发送邮件(使用Wamp、Xampp等)?PHPmail()似乎无法在本地工作 有人能给出说明吗?如果对本地xampp、wamp…有问题,您可以使用此库发送电子邮件 php,class.smtp.php 在电子邮件函数调用的文件中编写此代码 include('class.phpmailer.php'); $mail=new PHPMailer(); $mail->IsHTML(true); $mail->IsSMTP(); $mail->SMTPAuth=true; $mai

如何从本地主机SMTP发送邮件(使用Wamp、Xampp等)?PHP
mail()
似乎无法在本地工作


有人能给出说明吗?

如果对本地xampp、wamp…有问题,您可以使用此库发送电子邮件

php,class.smtp.php 在电子邮件函数调用的文件中编写此代码

include('class.phpmailer.php');
$mail=new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth=true;
$mail->SMTPSecure=“ssl”;
$mail->Host=“smtp.gmail.com”;
$mail->Port=465;
$mail->Username=“您的电子邮件ID”;
$mail->Password=“您的电子邮件密码”;
$fromname=“来自电子邮件中的姓名”;
$To=trim($email,“\r\n”);
$t内容=“”;
$t内容=”
你的文字
名称:“.trim(名称“\r\n”)。”
文本:“.$ABCD。”
";
$mail->From=“From email”;
$mail->FromName=$FromName;
$mail->Subject=“您的详细信息。”;
$mail->Body=$t内容;
$mail->AddAddress($To);
$mail->set('X-Priority','1')//优先级1=高,3=正常,5=低
$mail->Send();

如果在php.ini中指定了smtp服务器和smtp端口,则可以直接从php mail()函数发送邮件,首先向ISP询问smtp服务器凭据

SMTP = smtp.wlink.com.np //put your ISP's smtp server

smtp_port = 25 // your ISP's smtp port.
然后重新启动apache服务器,它就会开始工作。享受…

方法1(首选)-使用
安装后,您需要以下配置才能从wampserver正确发送邮件:

1) When you first open hMailServer Administrator, you need to add a new domain.
2) Click on the "Add Domain ..." button at the Welcome page. 
3) Under the domain text field, enter your computer's IP, in this case it should be 127.0.0.1.
4) Click on the Save button.
5) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
6) Enter "localhost" in the localhost name field.
7) Click on the Save button.
如果您需要使用另一台计算机的收件人发送邮件,则需要允许从外部帐户到外部帐户的传递。为此,请执行以下步骤:

1) Go to Settings>Advanced>IP Ranges and double click on "My Computer" which should have IP address of 127.0.0.1
2) Check the Allow Deliveries from External to External accounts checkbox.
3) Save settings using Save button.
(然而,Windows Live/Hotmail拒绝了所有来自大多数家用电脑使用的动态IP的电子邮件。解决方法是使用Gmail帐户)

使用Gmail用户的注意事项: (注意,From字段不适用于gmail)
*p、 美国。对于某些人,可能还需要在以下位置解开
要求SMTP身份验证下的所有标记:

  • 对于本地:设置>高级>IP范围>“我的电脑”
  • 对于外部:设置>高级>IP范围>“互联网”

方法2-使用SendMail 你可以用


方法3-使用不同的方法
如果你们中的任何一个人在遵循Afwe Wef给出的答案后出现如下错误,请使用任何一个。

 Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response:

 550 The address is not valid. in c:\wamp\www\email.php
进入valideaccount@gmail.com作为您用于在sendmail_前面配置hMailserver的电子邮件id

你的问题会解决的

在windows 8上的Wamp server2.2(Apache 2.2.22,php 5.3.13)上测试

如果您也遇到以下错误

"APPLICATION"   6364    "2014-03-24 13:13:33.979"   "SMTPDeliverer - Message 2: Relaying to host smtp.gmail.com."
"APPLICATION"   6364    "2014-03-24 13:13:34.415"   "SMTPDeliverer - Message 2: Message could not be delivered. Scheduling it for later delivery in 60 minutes."
"APPLICATION"   6364    "2014-03-24 13:13:34.430"   "SMTPDeliverer - Message 2: Message delivery thread completed."

您可能忘记将端口从25更改为465,以下是实现此目的的步骤:

  • 通过以下链接下载sendmail.zip

    • 现在,提取文件夹并将其放入C:/wamp/。确保这四个文件存在:sendmail.exe、libeay32.dll、ssleay32.ddl和sendmail.ini
    • 打开sendmail.ini并按如下方式设置配置:

    • smtp_server=smtp.gmail.com

    • smtp_端口=465
    • smtp_ssl=ssl
    • 默认\u域=本地主机
    • error\u logfile=error.log
    • debug_logfile=debug.log
    • auth\u username=[您的\u gmail\u帐户\u username]@gmail.com
    • auth\u password=[您的\u gmail\u帐户\u密码]
    • pop3_服务器=
    • pop3_用户名=
    • pop3_密码=
    • 强制发送器=
    • 强制接收=
    • 主机名=本地主机

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

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

    • 接下来,在php下启用php_openssl和php_套接字

    • 打开php.ini并按照下面的代码进行配置。基本上,您只需设置sendmail\u路径

  • 重新启动Wamp服务器

我希望这对您有用。

我更喜欢使用PHPMailer脚本从本地主机发送电子邮件,因为它允许我将我的Gmail帐户用作SMTP。您可以从中找到PHPMailer。有关如何将gmail用作SMTP或任何其他SMTP的帮助,请访问。希望这有帮助

使用xampp或wampp,您需要配置mercury以从本地主机发送邮件。你是在要求配置吗?techwheels的配置适合我<代码>:)
答案很好,很有效。除此之外,我还需要在“高级->ip范围->我的计算机”下取消选中“需要SMTP身份验证”下的所有内容,因为php mail()没有可用的内容。我按照您的所有步骤操作,但在Apache中启用-ssl_模块后,wamp服务器停止运行。当您说:“访问您的电子邮件帐户”时,你是在谈论我的个人gmail账户(想知道它和这些有什么关系)还是其他账户???
 Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response:

 550 The address is not valid. in c:\wamp\www\email.php
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = valideaccount@gmail.com
"APPLICATION"   6364    "2014-03-24 13:13:33.979"   "SMTPDeliverer - Message 2: Relaying to host smtp.gmail.com."
"APPLICATION"   6364    "2014-03-24 13:13:34.415"   "SMTPDeliverer - Message 2: Message could not be delivered. Scheduling it for later delivery in 60 minutes."
"APPLICATION"   6364    "2014-03-24 13:13:34.430"   "SMTPDeliverer - Message 2: Message delivery thread completed."
[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"