Dragen Posted February 15, 2008 Share Posted February 15, 2008 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 More sharing options...
cooldude832 Posted February 15, 2008 Share Posted February 15, 2008 you don't need the == true in the first if statement as mail returns a TRUE/FALSE as the function return so your if statement is satisfied by saying [ode] <?php if(mail()){ #it went } else{ #no good } ?> trry that and see what happens Link to comment https://forums.phpfreaks.com/topic/91266-mail-not-working-and-no-error-message/#findComment-467729 Share on other sites More sharing options...
Dragen Posted February 15, 2008 Author Share Posted February 15, 2008 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 https://forums.phpfreaks.com/topic/91266-mail-not-working-and-no-error-message/#findComment-467733 Share on other sites More sharing options...
cooldude832 Posted February 15, 2008 Share Posted February 15, 2008 can u force any php errors, maybe you are supressing errors somehow Link to comment https://forums.phpfreaks.com/topic/91266-mail-not-working-and-no-error-message/#findComment-467736 Share on other sites More sharing options...
Dragen Posted February 15, 2008 Author Share Posted February 15, 2008 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 https://forums.phpfreaks.com/topic/91266-mail-not-working-and-no-error-message/#findComment-467752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.