Jump to content

mail() function...


kevin7

Recommended Posts


<?

$to = 'xxx@gmail.com';
$subject = 'Testing of email';
$message = '<b>yo</b>, whassup?';
$headers = "From: someone@gmail.com\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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.