mem0ri Posted March 10, 2007 Share Posted March 10, 2007 Here I go again...mail() seems to be the hardest PHP function in the world to get working right (at least for me)... Here is my code for the entire page: <?php $terms = explode(",",$_POST['terms']); //a CSV from a form previous $sendto = explode(",", $_POST['boxarray']); //another CSV from a form previous if(!$terms[0]) $terms[0] = 0; //fixing the terms array to always send at least a 0 for receiving code if(!$terms[1]) $terms[1] = 0; if(!$terms[2]) $terms[2] = 0; if(!$terms[3]) $terms[3] = 0; $csvlist = $_POST['intvl'].",".$_POST['price'].",".$terms[0].",".$terms[1].",".$terms[2].",".$terms[3].",". $_POST['prop'].",".$_POST['integrate'].",".$_POST['auto'].",".$_POST['index']; $eol="\r\n"; $fromaddress = "[email protected]"; //I actually have my email in there...just takin' it out for everyone. ini_set ("sendmail_from","[email protected]"); $headers = 'From: Co<'.$fromaddress.'>'.$eol; $headers .= 'Reply-To: Co<'.$fromaddress.'>'.$eol; $headers .= 'Return-Path: Co<'.$fromaddress.'>'.$eol; $headers .= "Message-ID: <".$now." Server@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; $notice = "Configuration changes sent to: "; for($x = 0; $x < count($sendto); $x++) { $key = $sendto[$x]; $sendaddress = $key."@myaddress.com"; if($key != "" && $key != NULL) $sent = mail($sendaddress,$av,$csvlist,$headers); //I know it's redundant, but I wanted to be sure anyway. $notice.=$key."@myaddress.com "; if($sent == FALSE) $notice.=" SEND FAILED "; } ?> No matter where I try to send my e-mail, it fails automatically. I should also note that the $av subject variable is not 'blank'...it's defined on an Index page that calls this function page with an include. Hosted on a Bluehost.com server... PHP 5.1.6 Linux Apache 1.3.37 PERL 5.8.7 Default sendmail path. Quote Link to comment https://forums.phpfreaks.com/topic/42091-killing-myself-over-mail/ Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 Why not test if your send mail is working, create a new file with simply this: <?php mail('[email protected]', 'Subject Here', 'Message Here'); ?> See if that works, if it does try adding your headers to the mix. Remember to debug something KISS it (KEEP IT SIMPLE STUPID). Once you know the basic portion is working, add more to it slowly and keep testing. --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42091-killing-myself-over-mail/#findComment-204233 Share on other sites More sharing options...
mem0ri Posted March 10, 2007 Author Share Posted March 10, 2007 Appreciated frost. Sometimes...it's late...and I forget all about doin' a drill-down in the right way...start lookin' for error messages...heh. It's an old habit that I need to break out of. Anyway...after drilling down the exact problem, it seems that: If I attempt to change the 'from' portion of the header, my send fails. Otherwise, it succeeds. Is there any type of setting I should be looking for that forces a send from a particular address and causes a failure if there is an attempted change? Quote Link to comment https://forums.phpfreaks.com/topic/42091-killing-myself-over-mail/#findComment-204246 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.