Jump to content

trouble in sending mail


shane07

Recommended Posts

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

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!

 

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.