Page 1 of 1

How can I use mail function?

Posted: Wed Jul 08, 2009 6:50 am
by zizhang
I don't know how to use mail function to send a mail?

I look up the manual on http://cn2.php.net/manual/en/function.mail.php

But I still failed to follow the little example in the manual

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('caffeinated@example.com', 'My Subject', $message);
?>

the error report is "Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache2.2.11\htdocs\mail.php on line 9"

How can I modify this code and php.ini to get through this problem? Thanks a lot! :lol:

Re: How can I use mail function?

Posted: Wed Jul 08, 2009 7:02 am
by SvanteH

Code: Select all

$header = "'From: webmaster@example.com";
mail('caffeinated@example.com', 'My Subject', $message, $header);