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
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..

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.