Duofilm Posted March 22, 2012 Share Posted March 22, 2012 As my titel indicates, I have a problem with a piece of code I wrote some time ago. Everything in my mail form is fine and the mails do get send. But they don't always arrive (checked spam folder). Hotmail or example arrives but a normal email adres from a provider does not. Could this have something to do with SMTP ? could I add this to my code ? I tryed some but so far it does not work, In the code below you can see my working code as it is & the tests I tryed and didn't work out that well. <?php $fromemail="No-Reply <ikwerkthuis.be>"; // change here if you want $toemail=$naarwie; // change here if you want $sub="Online info aanvraag"; // change here if you want $success_page_name="bedankt.html"; ////// do not change in following if($_SERVER['REQUEST_METHOD']=="POST") { $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1'])); $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2'])); $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3'])); $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4'])); $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5'])); $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6'])); $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7'])); $contentmsg=stripslashes('<br><b><font style=color:#CC3300>'. $sub .'</font></b><br> <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Voornaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_1 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Achternaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_2 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>E-mail *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_3 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Telefoon *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_4 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Werkstatus *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_5 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Leeftijd *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_6 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Regio *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_7 .'</td> </tr> </table><br> Contactpersoon: '. $naarwie .'<br> IP: '. $IP .'<br> Date: '. $DATE .'<br> Time: '. $TIME .' '); //// $headers = "MIME-Version: 1.0 "; $headers .= "Content-type: text/html; charset=iso-8859-1 "; $from=$fromemail; $headers .= "From: ".$from." "; @mail($toemail,$sub,$contentmsg,$headers);?> The code below is the code I tryed to apply to the code above that work. <?php $fromemail="No-Reply <[email protected]>"; // change here if you want $toemail=$naarwie; // change here if you want $sub="Online info aanvraag"; // change here if you want $success_page_name="bedankt.html"; $host = "ikwerkthuis.be"; $username = "[email protected]"; $password = "hl2012"; ////// do not change in following if($_SERVER['REQUEST_METHOD']=="POST") { $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1'])); $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2'])); $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3'])); $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4'])); $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5'])); $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6'])); $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7'])); $contentmsg=stripslashes('<br><b><font style=color:#CC3300>'. $sub .'</font></b><br> <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Voornaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_1 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Achternaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_2 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>E-mail *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_3 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Telefoon *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_4 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Werkstatus *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_5 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Leeftijd *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_6 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Regio *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_7 .'</td> </tr> </table><br> Contactpersoon: '. $naarwie .'<br> IP: '. $IP .'<br> Date: '. $DATE .'<br> Time: '. $TIME .' '); //// $headers = "MIME-Version: 1.0 "; $headers .= "Content-type: text/html; charset=iso-8859-1 "; $from=$fromemail; $headers .= "From: ".$from." "; $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); @mail = $smtp->send($toemail,$sub,$contentmsg,$headers); ?> I hope someone can help me out. Thanks in advance ! Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/ Share on other sites More sharing options...
Muddy_Funster Posted March 22, 2012 Share Posted March 22, 2012 you can't just drop smtp details into the mail script, you need to set them in your ini files and even then that will only work on Linux servers. Your issue is most likely that you are not building full headers. A lot of ISP's will just dump mail without even thinking if the headers are malformed or incomplete, it won't flag the message as spam, it will just delete it from the server and that's the end of it. If it was an smtp issue you wouldn't be getting any of the mails out (trust me). SMTP is the outbound part of the process, not the inbound part. Look up how to build headers that are complete and accurate, this should fix your issue. Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/#findComment-1330188 Share on other sites More sharing options...
Duofilm Posted March 22, 2012 Author Share Posted March 22, 2012 I looked it up made some minor changes... Since there wasn't much to change according to what I found on the internet. <?php $fromemail="No-Reply <ikwerkthuis.be>"; // change here if you want $toemail=$naarwie; // change here if you want $sub="Online info aanvraag"; // change here if you want $contentmsg="blabla" $success_page_name="bedankt.html"; $headers = "From:".$fromemail.""; $headers .= "MIME-Version: 1.0"; $headers .= "Content-type: text/html; charset=iso-8859-1"; @mail($toemail,$sub,$contentmsg,$headers); ?> Its still doesn't send to all emails some work some don't.. any other ideas ? or anything wrong with my headers here ? Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/#findComment-1330202 Share on other sites More sharing options...
Muddy_Funster Posted March 22, 2012 Share Posted March 22, 2012 $fromemail="No-Reply <ikwerkthuis.be>" This isn't a valid email address, so can be deamed as malformed. the email address doesn not need to resolve, just make sure it's in the format of an actual mail address and has a valid domain. Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/#findComment-1330214 Share on other sites More sharing options...
Duofilm Posted March 22, 2012 Author Share Posted March 22, 2012 I changed the From to a valid email adres that is in use even. It doesn't change anything Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/#findComment-1330221 Share on other sites More sharing options...
Muddy_Funster Posted March 22, 2012 Share Posted March 22, 2012 can you post up the headers from one of the accounts that is recieving the message? Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/#findComment-1330227 Share on other sites More sharing options...
Duofilm Posted March 24, 2012 Author Share Posted March 24, 2012 I'm not sure I understand what you mean ? You mean to post the email ? that ppl are recieving ? completly ? Quote Link to comment https://forums.phpfreaks.com/topic/259490-php-mail-sending-form-not-arriving-in-all-mailboxes-smtp-problem/#findComment-1330694 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.