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
lauthiamkok
Forum Contributor
Posts: 153 Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom
Post
by lauthiamkok » Tue Jan 26, 2010 4:14 pm
Hi,
Can anyone tell what I have done wrong with mail(); it won't send any mails at all...
Code: Select all
if(!empty($mai_content))
{
$to_email = 'me1@yahoo.co.uk';
$from_name = 'sender';
$from_email = 'sender@yahoo.co.uk';
$subject = "You have a comment!";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "From: $from_name <$from_email>\r\n";
$headers .= "Cc: me2@yahoo.co.uk\r\n";
$headers .= 'Bcc: me3@lauthiamkok.net, me4@lauthiamkok.net';
$content = stripslashes($row_mailing_tmp['mai_content']);
$sentmail = mail($to_email,$subject,$content,$headers);
}
I have spent my entire evening but still cannot find out what is wrong with it.
Many thanks,
Lau
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Tue Jan 26, 2010 5:11 pm
I'm only speculating:
Is there a typo in the variable name $mai_content?
There is no "\r\n" after your final header
Have you tried removing the headers all together to see if the email goes through?
Have you tried removing the From Name, and send it only with an address?
Does the From email address exist on your email server?
Most of these are problems I've encountered on my own, but there isnt alot to go on.
lauthiamkok
Forum Contributor
Posts: 153 Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom
Post
by lauthiamkok » Tue Jan 26, 2010 5:45 pm
flying_circus wrote: I'm only speculating:
Is there a typo in the variable name $mai_content?
There is no "\r\n" after your final header
Have you tried removing the headers all together to see if the email goes through?
Have you tried removing the From Name, and send it only with an address?
Does the From email address exist on your email server?
Most of these are problems I've encountered on my own, but there isnt alot to go on.
I have tried as simple as this one but it still won't work!
mail('
me1@yahoo.co.uk ','subject','message');