简体   繁体   中英

PHP mail function fails to send mail to gmail

I am using mail function to send mail via php script to gmail. Here is the code :

if( mail($to,$subject,$message,$headers))   
    echo "mail sent";
else
    echo "mail not sent";

Every time it echos "mail not sent". It fails for gmail but works for other servers.

Any idea why so? Thanks.

You should start with checking the SMTP configration(SMTP stands for simple mail transfer protocol). You can find it in the php.ini; look for the line that reads [mail function]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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