bugs with php mail()

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

Post Reply
lauthiamkok
Forum Contributor
Posts: 153
Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom

bugs with php mail()

Post by lauthiamkok »

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
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: bugs with php mail()

Post by flying_circus »

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

Re: bugs with php mail()

Post by lauthiamkok »

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! :banghead:

mail('me1@yahoo.co.uk','subject','message');
Post Reply