shane07 Posted December 24, 2008 Share Posted December 24, 2008 Hello I used following script to send an email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "From: ".$fromName."<".$fromAddress.">"."\r\n". "To:".$toAddress."\r\n"; if(mail($toAddress,$mailSubject,nl2br($mailBody),$headers)) return true; else return false; It was working, but not working any more. also I tried to send email simply using mail('[email protected]','test subject','test email','') But is not working either The page shows no error message or no warnings. I even checked my 'junk' folder but I got nothing. Link to comment https://forums.phpfreaks.com/topic/138291-trouble-in-sending-mail/ Share on other sites More sharing options...
careym1989 Posted December 24, 2008 Share Posted December 24, 2008 EDIT: Forget that - I think I see your problem. I don't see a mail() function before your if() statement. All I see is your mail() function INSIDE the if() statement. I would do this: $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "From: ".$fromName."<".$fromAddress.">"."\r\n". "To:".$toAddress."\r\n"; $query = mail($toAddress,$mailSubject,nl2br($mailBody),$headers) if($query) { return true; } else { return false; } Sorry if this is clearly not the solution -- just trying to help! Link to comment https://forums.phpfreaks.com/topic/138291-trouble-in-sending-mail/#findComment-723062 Share on other sites More sharing options...
shane07 Posted December 24, 2008 Author Share Posted December 24, 2008 I tested your script. It says 'Error. Try Again'. What does this mean? As till yesterday my script was working well. Is anything wrong with the server? I just replied to a very similar message a couple of threads down, but try something like this: <?php error_reporting(E_ALL); $to = "[email protected]"; $subject = "Hello. This is a test!"; $msg = "This is a simple test email. I hope this works."; $query = mail($to, $subject, $msg); if ($query) { echo "Success!"; } else { echo "Error. Try again."; } ?> If it echoes back "Success!" then it should work! Link to comment https://forums.phpfreaks.com/topic/138291-trouble-in-sending-mail/#findComment-723065 Share on other sites More sharing options...
careym1989 Posted December 24, 2008 Share Posted December 24, 2008 Hmm, okay. Yes, there might be a problem with your server. I'm a pretty big noob when it comes to servers. Link to comment https://forums.phpfreaks.com/topic/138291-trouble-in-sending-mail/#findComment-723067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.