redIT Customer Support Portal Language
 
HomeKnowledge BaseHostingUsing PHP mail() function
Information
Article ID6
Created On4/22/2010
Modified4/22/2010
Share With Others
Using PHP mail() function
To enable the PHP mail() function to fire correctly on a Microsoft Windows Server an extra segment of code is required before the mail() section is called.

The extra lines required are:

ini_set('SMTP', 'mail.yourdomain.co.uk' );
ini_set('sendmail_from', 'someone@yourdomain.co.uk');



A basic example of a functioning PHP mail script is below:

$Name = "A. N. Other"; //The senders name as you wish it to appear on the e-Mail header
$email = "someone@yourdomain.co.uk"; //The senders e-mail adress
$recipient = "someone@exmpledomain.co.uk"; //The recipients e-Mail address
$mail_body = "This is the message"; //The main e-Mail body (the message
$subject = "PHP mail() from a Windows Server"; //The e-Mail subject line
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

ini_set('SMTP', 'mail.yourdomain.co.uk' );
ini_set('sendmail_from', 'someone@yourdomain.co.uk');
mail($recipient, $subject, $mail_body, $header); //send the e-Mail command