php 在php中使用xampp发送邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16003058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 10:21:21  来源:igfitidea点击:

send mail using xampp in php

phpsendmail

提问by user2280276

I've seen a lot of videos but haven't got a hang of how to send mailin php.

我看过很多视频,但对如何使用send mailphp 一无所知。

I've configured the smtp portand serveralong with php.inifile and also the sendmail.inifile, changed the auth_usernameand password. However, the code below still does not work!

我已经配置了smtp portandserverphp.ini文件以及sendmail.ini文件,更改了auth_usernamepassword。但是,下面的代码仍然不起作用!

<?php
    mail('[email protected]','Hello','Testing Testing','From:[email protected]');
?>

Do I need to download anything or change the gmail settings?

我需要下载任何东西或更改 Gmail 设置吗?

采纳答案by Harshavardhan

It's very easy to configure php.ini for sending e-mails from your server.You just need to configure php.ini and sendmail.inicorrectly.

配置 php.ini 以从您的服务器发送电子邮件非常容易。您只需要php.ini and sendmail.ini正确配置即可。

First you have to configure sendmail_path in your php.ini file it should have to point to executable sendmail file with proper flags

首先,您必须在 php.ini 文件中配置 sendmail_path,它必须指向具有正确标志的可执行 sendmail 文件

for example , ;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"(which is already in your php.ini file need to just remove comment) and other assignments to sendmail_path need to be commented.

例如, ;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"(它已经在你的 php.ini 文件中需要删除注释)和其他对 sendmail_path 的分配需要被注释。

after configuring php.ini file you need to configure sendmail.ini file ,in that

配置 php.ini 文件后,您需要配置 sendmail.ini 文件,其中

first smtp_server=mail.gmail.com(as you want to use gmail as smtp server), second smtp_port=465(if not worked try 587), third auth_username= [email protected]auth_password=yourpassword

第一个smtp_server=mail.gmail.com(因为你想使用 gmail 作为 smtp 服务器),第二个smtp_port=465(如果不工作,请尝试 587),第三个auth_username= [email protected]auth_password=yourpassword

after this restart your server.

在此之后重新启动您的服务器。