obay Posted June 22, 2007 Share Posted June 22, 2007 This works: $to = "[email protected]"; $subject = "CONTACT FORM"; $body = "test"; mail($to, $subject, $body); But when I add an additional parameter $headers, it doesn't work: $to = "[email protected]"; $subject = "CONTACT FORM"; $headers = "From: My Name Here"; $body = "test"; mail($to, $subject, $body, $headers); What could I be doing wrong? Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/56795-why-does-the-php-mail-function-not-work-when-adding-a-headers-parameter/ Share on other sites More sharing options...
chronister Posted June 23, 2007 Share Posted June 23, 2007 Please provide more info. What error are you getting? Is the mail being sent / recieved? Did you check the spam box? Here is a mail function I use. It works like a charm. <?php $headers ="MIME-Version: 1.0" . "\r\n"; $headers .= "X-Mailer: PHP/" .phpversion() ."\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'Return-Path: [email protected]'."\r\n"; $headers .= "From: YOUR NAME HERE <[email protected]>"; $address=$email; $subject = 'YOUR SUBJECT'; $body='This is the body of the email'; mail($address , $subject, $body, $headers); ?> Hope it helps a bit Link to comment https://forums.phpfreaks.com/topic/56795-why-does-the-php-mail-function-not-work-when-adding-a-headers-parameter/#findComment-280591 Share on other sites More sharing options...
obay Posted June 23, 2007 Author Share Posted June 23, 2007 Thank you very much! I changed the from line into this $headers = "From: YOUR NAME HERE <[email protected]>"; as you suggested. It works now! Thanks very much!! =) Link to comment https://forums.phpfreaks.com/topic/56795-why-does-the-php-mail-function-not-work-when-adding-a-headers-parameter/#findComment-280608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.