how to send a php mail?

Status
Not open for further replies.

logicours44

New Member
Messages
1
Reaction score
0
Points
0
hi,
I am unable to send a mail via the php function mail(). Is it possible? How?
my code is

<?php
$headers ='From: "nom"<adresse@fai.fr>'."\n";
$headers .='Reply-To: adresse_de_reponse@fai.fr'."\n";
$headers .='Content-Type: text/plain; charset="iso-8859-1"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';

if(mail('logicours@live.fr', 'Sujet', 'Message de test', $headers))
{
echo 'yes';
}
else
{
echo 'no';
}
?>
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP:
$from_name="Barefoot" ;
$from = "nonikes@shoeless.x10.bz";
$to="myaddress@gmail.com";

$mailbody="test message  sent on: \n" . date('l jS \of F Y h:i:s A');
$subject="test of PHP mail() sending mail." ;

$headers = "Content-type: text/plain; charset=windows-1251 \r\n";
$headers .= "From: $from_name <$from>\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

$resp = mail($to, $subject, $mailbody, $headers);

The above code works on Chopin, a free server.

If $resp is true, the system has sent it.
But some email hosts (Hotmail) will bounce it back (check your Webmail for delivery failure notice) or put it in a spam folder.
 
Status
Not open for further replies.
Top