send mail using xampp in php

丶灬走出姿态 提交于 2019-12-04 08:37:42

问题


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

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. 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?


回答1:


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.

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

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.

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

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

after this restart your server.



来源:https://stackoverflow.com/questions/16003058/send-mail-using-xampp-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!