Jump to content

mail() function...


kevin7

Recommended Posts


<?

$to = '[email protected]';
$subject = 'Testing of email';
$message = '<b>yo</b>, whassup?';
$headers = "From: [email protected]\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
if (mail($to, $subject, $message, $headers)) {
echo "Mail Sent";
} else {
echo "Mail Failed";
}
?>

 

I'm creating a script that will allow client to send mail to another client using a form with php mail() function... I have uploaded this script to the server, and i'm able to send a mail back to the server email address, and then, i tried to send mail to my gmail account, i received nothing, i tried and tried, and use the code provided in php.net/mail still no clue... i hv totally ran out of ideas and im here to seek for help...

can anyone tell me what's wrong with my code, or perhaps... can you show me the code that will able to send to other mail services such as yahoo, gmail, hotmail and so on...

 

and, i hv looked at the spam section of gmail, nothing was found..

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/61090-mail-function/
Share on other sites

From what i can see, the script looks ok. If it send email internally then it has to do with the mail server configuration. Maybe the external gateway requires SMPT Authentication to relay your mail, so it may need username and password. Or just check if gmail or any other free email account is blocked by the mail server. Anyway i think it has nothing to do with your php script.

Link to comment
https://forums.phpfreaks.com/topic/61090-mail-function/#findComment-306060
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.