简体   繁体   English

如何配置ini文件用PHP发送邮件

[英]How to configure ini file to send mail with php

I am using wampp server and I try to send mail with php script. 我正在使用wampp服务器,我尝试用PHP脚本发送邮件。 But I am getting errors. 但我收到了错误。

I configured php.ini file in different ways and wamp server does not have a sendmail file. 我以不同的方式配置了php.ini文件,而wamp服务器没有sendmail文件。

So how to setup this? 那么如何设置呢?

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost


; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from =myMail1@gmail.com

   <?php


    $from = "myMail1@gmail.com";
    $to = "test_one@outlook.com";
    $subject = "Checking PHP mail";
    $message = "PHP mail works just fine";
    $headers = "From:" . $from;
    mail($to,$subject,$message, $headers);


?>

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\\wamp64\\www\\sendMail\\index.php on line 9 警告:mail():无法连接到“localhost”端口25的邮件服务器,验证php.ini中的“SMTP”和“smtp_port”设置或使用C:\\ wamp64 \\ www \\ sendMail \\ index.php中的ini_set()在第9行

I want to eliminate this error. 我想消除这个错误。 I restarted my server couple of times. 我重启了我的服务器几次。

you are trying to use your own server as smpt server (have you?) try with smtp.gmail.com over port 587 您正在尝试使用自己的服务器作为smpt服务器(是吗?)尝试使用smtp.gmail.com通过端口587

https://support.google.com/a/answer/176600 https://support.google.com/a/answer/176600

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM