简体   繁体   English

在php中使用xampp发送邮件

[英]send mail using xampp in php

I've seen a lot of videos but haven't got a hang of how to send mail in php. 我已经看过很多视频,但还没有了解如何在php中send mail

I've configured the smtp port and server along with php.ini file and also the sendmail.ini file, changed the auth_username and password . 我已经配置了smtp portserver以及php.ini文件和sendmail.ini文件,更改了auth_usernamepassword However, the code below still does not work! 但是,下面的代码仍然无效!

<?php
    mail('xyz@gmail.com','Hello','Testing Testing','From:abc@gmail.com');
?>

Do I need to download anything or change the gmail settings? 我是否需要下载任何内容或更改Gmail设置?

It's very easy to configure php.ini for sending e-mails from your server.You just need to configure php.ini and sendmail.ini correctly. 配置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= yourid@gmail.com auth_password=yourpassword 第一个smtp_server=mail.gmail.com (因为你想使用gmail作为smtp服务器),第二个smtp_port=465 (如果没有工作尝试587),第三个auth_username= yourid@gmail.com auth_password=yourpassword

after this restart your server. 在此之后重启您的服务器。

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

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