lovephp Posted November 21, 2012 Share Posted November 21, 2012 guys why is it that when i add email address to $headers reply or from then the email will not be delivered to email address eg: $headers = "From: Tech Innovators support@techinnovators.com\r\n"; $headers .= 'MIME-Version: 1.0' . "\n"; or $headers = "From: support@techinnovators.com\r\n"; $headers .= 'MIME-Version: 1.0' . "\n"; the above codes does not send the email but if i do like below without any email then only the email gets delivered and also the email address lookis like support@cp-645.webhostbox.net $headers = "From: Tech Innovators \r\n"; $headers .= 'MIME-Version: 1.0' . "\n"; Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/ Share on other sites More sharing options...
Muddy_Funster Posted November 21, 2012 Share Posted November 21, 2012 mail headers are a bugger to get right, try wrapping the email address in square brackets, and/or put a space at the end. Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1394246 Share on other sites More sharing options...
lovephp Posted November 26, 2012 Author Share Posted November 26, 2012 tried it does not work. if i add email address on from: then the email does not get sent and if i add no email address on from: then it sends the email as support@cp-645.webhostbox.net Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395202 Share on other sites More sharing options...
mrMarcus Posted November 26, 2012 Share Posted November 26, 2012 @Muddy_Funster You mean wrapping the address in: John Doe <example@example.com> @lovephp Can you post your mail() function? Are you adding the $headers variable to the mail function? It is the fourth argument. Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395206 Share on other sites More sharing options...
lovephp Posted November 26, 2012 Author Share Posted November 26, 2012 yes tried like John Doe <example@example.com> and John Doe example@example.com and also $email = $_POST['email']; John Doe {$email} but the email will not be delivered... ad if i do just the from: John Doe then its sent but as support@cp-645.webhostbox.net Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395207 Share on other sites More sharing options...
mrMarcus Posted November 26, 2012 Share Posted November 26, 2012 Can you please post your mail function. Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395209 Share on other sites More sharing options...
lovephp Posted November 26, 2012 Author Share Posted November 26, 2012 its like this $headers = "From: $company_name <$company_email>\r\n"; $headers .= "Reply-To: <$company_email>\r\n"; $headers .= "Return-Path: $company_email\r\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'Content-type: text/html; charset=us-ascii' . "\r\n"; 'X-Mailer: PHP/' . phpversion(); Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395210 Share on other sites More sharing options...
mrMarcus Posted November 26, 2012 Share Posted November 26, 2012 That's not your mail function. Your mail function looks something like this: mail($to, $subject, $body, $headers); Please post that ^ And why do you have 2 Content-type headers? Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395213 Share on other sites More sharing options...
lovephp Posted November 26, 2012 Author Share Posted November 26, 2012 (edited) oh just to be on safe side added 2 Conten-type and do you mean this $subject = "(Confirmation) - $company_name"; mail($to, $subject, $message, $headers); i have tried my coding on 2 web hosts on 1 its works like charm but on 1 thi error happens Edited November 26, 2012 by lovephp Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395215 Share on other sites More sharing options...
mrMarcus Posted November 26, 2012 Share Posted November 26, 2012 Adding additional, useless code to be on the "safe side" is no good. You cannot use more than a single Content-type. You could add 50 Content-type's but only one (the first one) will be used. Does $company_email match the domain name? Or is it a @gmail.com address or something of the like? Try the following: mail($to, $subject, $message, $headers, "-f $company_name"); Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395217 Share on other sites More sharing options...
Muddy_Funster Posted November 26, 2012 Share Posted November 26, 2012 Adding additional, useless code to be on the "safe side" is no good. You cannot use more than a single Content-type. You could add 50 Content-type's but only one (the first one) will be used. ... unless it's a multipart mail, then you can have a different content type for each part - I know that's not the point you are making, but just to keep it all clear. Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395220 Share on other sites More sharing options...
mrMarcus Posted November 26, 2012 Share Posted November 26, 2012 unless it's a multipart mail, then you can have a different content type for each part - I know that's not the point you are making, but just to keep it all clear. You are correct. However, I was referring to OP's current usage. Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395224 Share on other sites More sharing options...
lovephp Posted November 27, 2012 Author Share Posted November 27, 2012 Adding additional, useless code to be on the "safe side" is no good. You cannot use more than a single Content-type. You could add 50 Content-type's but only one (the first one) will be used. Does $company_email match the domain name? Or is it a @gmail.com address or something of the like? Try the following: mail($to, $subject, $message, $headers, "-f $company_name"); $company_email is not gmail its email@somedomain.com but $to is gmail, yahoo hotmail email ids which i input on form. the email goes without any issue to email@somedomain.com but does not goes to yahoo, gmail or hotmail if add from: email address Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395547 Share on other sites More sharing options...
mrMarcus Posted November 27, 2012 Share Posted November 27, 2012 Does the email address in question match the domain/server? When I checked out techinnovators.com, there is no site. A DNS check revealed different nameservers than webhostbox.net. Different hosts will only allow certain header formations. Your best bet is to contact them and see what they allow. Quote Link to comment https://forums.phpfreaks.com/topic/271007-mail-headers-issue/#findComment-1395566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.