mail not arriving at destination

the mail() function

Moderators: macek, egami, gesf

Dom
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Jan 21, 2012 2:55 am

mail not arriving at destination

Postby Dom » Sat Jan 21, 2012 3:15 am

I admit I am very new to php coding and hoped to find sme helpful articles here, but didn't know where to look :oops:

I wrote a very simple bit of code to check whether the mail() function works:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mail test</title>
</head>

<body>
<?php
mail('dominicdem@gmail.com','test email from mail_php','Saturday 21 Jan 2012','From: webmaster@stmarysplattchurch.org.uk' . "\r\n" . 'Reply-To: contact@stmarysplattchurch.org.uk' . "\r\n" . 'X-Mailer: PHP/' . phpversion());
echo "mail sent";
?>
</body>
</html>

It echoes mail sent on loading the page, but nothing arrives at gmail. I checked with my host and they said my code should work, and that there is nothing server side that would stop it working. Can any of you guys think of anything?

Thanks in advance

Dom

rupali
New php-forum User
New php-forum User
Posts: 140
Joined: Thu Oct 13, 2011 10:32 pm
Location: Chandigarh, INDIA

Re: mail not arriving at destination

Postby rupali » Sat Jan 21, 2012 4:06 am

hello,

i think your defined syntax is not correct, so try like this as given below :

<?php
$from = "webmaster@stmarysplattchurch.org.uk";
$to = "dominicdem@gmail.com";
$reply_to = "contact@stmarysplattchurch.org.uk"
$subject = "test email from mail_php";
$message= "test email !!!";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: '. $from . "\r\n";
$headers .= 'Reply-To: '.$reply_to."\r\n";


mail($to,$subject,$message,$headers);

echo "mail sent";
?>

Dom
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Jan 21, 2012 2:55 am

Re: mail not arriving at destination

Postby Dom » Sat Jan 21, 2012 4:16 am

Thanks Rupali - I'll give it a go

rupali
New php-forum User
New php-forum User
Posts: 140
Joined: Thu Oct 13, 2011 10:32 pm
Location: Chandigarh, INDIA

Re: mail not arriving at destination

Postby rupali » Sat Jan 21, 2012 7:31 pm

my pleasure Dom :)


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest