billy nugz Posted January 30, 2007 Share Posted January 30, 2007 Very new to php and dont really have a good understanding of it. but here is a code I use to send simple text based email. But this keeps going into the junk box and I have no idea why?[code]<?php/******************************************************************************\*******************************************************************************//*******************************************************************************/// Necessary Variables:$TO = "[email protected]"; // En: E-Mail of mail recipient. // Fr: E-Mail pour l'envoie. $DEFAULT_EXIT_PAGE = "confirm.htm"; // En: exit page. // Fr: page de sortie.// End Necessary Variables section/******************************************************************************/$headers = "From: $name <$email>\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n";$message = "";while (list($key, $val) = each($HTTP_POST_VARS)) { $message .= "$key : $val\n"; } $message .= "From: $name <$email>\n";mail($TO, $subject, $message, $headers); // En : Send mail // Fr : Envoi du mail if(! $exit_page) $exit_page = $DEFAULT_EXIT_PAGE;Header("Location: ".$exit_page); // Exit -> $exit_page?> [/code]Is there a better code I could use. I tryed to get a grasp on the php mailer tut and got real lostAny help would be great. My thanks in advance. Link to comment https://forums.phpfreaks.com/topic/36348-mail-going-into-junk-box/ Share on other sites More sharing options...
ted_chou12 Posted January 30, 2007 Share Posted January 30, 2007 i think it depends on your mail company, if you dont have the sender email address in your contact list, they automatically put it into junk box, so you need to add the address into your contact list or something.Try thatTed Link to comment https://forums.phpfreaks.com/topic/36348-mail-going-into-junk-box/#findComment-172826 Share on other sites More sharing options...
billy nugz Posted January 30, 2007 Author Share Posted January 30, 2007 That sound about right...I guess ??? but how would I go about doing that ? Link to comment https://forums.phpfreaks.com/topic/36348-mail-going-into-junk-box/#findComment-172856 Share on other sites More sharing options...
Psycho Posted January 30, 2007 Share Posted January 30, 2007 If you look at the manual for mail() you will see several comments at the bottom concerning different header parameters that can help avoid your mail from being flagged as spam: http://us2.php.net/mail Link to comment https://forums.phpfreaks.com/topic/36348-mail-going-into-junk-box/#findComment-172872 Share on other sites More sharing options...
billy nugz Posted January 30, 2007 Author Share Posted January 30, 2007 So somthing like this ? If so would I have to change fromaddress? [code]<?phpfunction send_mail($emailaddress, $fromaddress, $emailsubject, $body){ $eol="\r\n"; $mime_boundary=md5(time()); # Common Headers $headers .= 'From: MyName<'.$fromaddress.'>'.$eol; $headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol; $headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol; // these two to set reply address $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters # Boundry for marking the split & Multitype Headers $headers .= 'MIME-Version: 1.0'.$eol; $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol; $msg = "";/******************************************************************************\*******************************************************************************//*******************************************************************************/// Necessary Variables:$TO = "[email protected]"; // En: E-Mail of mail recipient. // Fr: E-Mail pour l'envoie. $DEFAULT_EXIT_PAGE = "confirm.htm"; // En: exit page. // Fr: page de sortie.// End Necessary Variables section/******************************************************************************/$message = "";while (list($key, $val) = each($HTTP_POST_VARS)) { $message .= "$key : $val\n"; } $message .= "From: $Name <$Email>\n";mail($TO, $subject, $message, $headers); // En : Send mail // Fr : Envoi du mail if(! $exit_page) $exit_page = $DEFAULT_EXIT_PAGE;Header("Location: ".$exit_page); // Exit -> $exit_page?> [/code]Thanks again guys Link to comment https://forums.phpfreaks.com/topic/36348-mail-going-into-junk-box/#findComment-173004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.