View Single Post
Old 21st April 2006, 19:37
sjau sjau is offline
Local Meanie
Join Date: Apr 2006
Location: Switzerland
Posts: 1,158
Thanks: 4
Thanked 58 Times in 54 Posts

For testing I would suggest to use the mail() examples in the php doc. If they don't work then there's some issue:

Example 907. Sending mail.
Using mail() to send a simple email:

copy to clipboard
// 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('', 'My Subject', $message);
Example 908. Sending mail with extra headers.
The addition of basic headers, telling the MUA the From and Reply-To addresses:

copy to clipboard
$to = '';
$subject = 'the subject';
$message = 'hello';
$headers = 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
Example 909. Sending mail with an additional command line parameter.
The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path.

copy to clipboard
mail('', 'the subject', 'the message', null,
Example 910. Sending HTML email
It is also possible to send HTML email with mail().

copy to clipboard
// multiple recipients
$to = '' . ', '; // note the comma
$to .= '';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<title>Birthday Reminders for August</title>
<p>Here are the birthdays upcoming in August!</p>

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <>, Kelly <>' . "\r\n";
$headers .= 'From: Birthday Reminder <>' . "\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc:' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
Reply With Quote