Page 1 of 1

bugs with php mail()

Posted: Tue Jan 26, 2010 4:14 pm
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

Re: bugs with php mail()

Posted: Tue Jan 26, 2010 5:11 pm
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.

Re: bugs with php mail()

Posted: Tue Jan 26, 2010 5:45 pm
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');