How can I use mail function?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zizhang
Forum Newbie
Posts: 1
Joined: Wed Jul 08, 2009 6:43 am

How can I use mail function?

Post 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:
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

Re: How can I use mail function?

Post by SvanteH »

Code: Select all

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