Jump to content

mail() not working and no error message?!


Dragen

Recommended Posts

I'm really stuck with a simple mail() function.

I'm using very similar code on another site (copied and pasted) and it seems to work fine, but when I try it on another it wont send the email.

Are there any instances when mail() returns false, without outputting an error?

I've got this code:

<?php
if(mail($this->to, $this->subject, $this->msg, $this->headers) == true){
return true;
}else{
$er->add('could not send email. please try again');
}
?>

If it returns true it should send the email, false and it outputs an error. I've got error reporting to E_ALL.

When I run the above code it outputs my custom error "could not send email. please try again", but outputs no error from php mail. This is baffling me, as I can't figure out what the problem is.

Link to comment
https://forums.phpfreaks.com/topic/91266-mail-not-working-and-no-error-message/
Share on other sites

nah, still no good.

The annoying thing is it works fine on another server, but the two servers should be identical so I can't see it as a server problem.

 

Should I post the code? it's a bit lengthy altogether, but I can't see anything wrong with it..

I never suppress errors whilst debugging.

I can force any amount of errors ;) so I know that errors should be output if they are there.

 

EDIT: okay I've solved that problem..

My host don't allow mail to be sent if either the to or from address isn't a valid email account on the server. I've changed the address to a valid one (as it was a no-reply@domain one) and now I receive no errors and it seems to have successfully sent.

 

Now to see if it did actually send. Before this problem, it was saying the message had been sent, but was never received (using a valid address).

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.