MyBB Community Forums

Full Version: mail() does not work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

We are using the mail()-function to inform about new PNs, etc. Somewhen it stopped working. I had the feeling it stopped with the update to 1.8.4 but the logs are talking about errors since 02.03.2015. But I found mails with the date 12.02.2015, so it is really strange and we don't know exactly when the problem started.

The error log says: "MyBB was unable to send the email using the PHP mail() function."

We tried a simple php-file:

<?php
   mail("[email protected]", "Testmail", "This is a test");
?>

Worked great.

<?php
   mail("[email protected]", "Testmail", "This is a test", "[email protected]");
?>

Worked great too.

We opened the file inc/mailhandlers/php.php and replaced

$sent = @mail($this->to, $this->subject, $this->message, trim($this->headers), $this->additional_parameters); 


with

$sent = @mail($this->to, $this->subject, $this->message, trim($this->headers)); 

Still the same error.

We have tried the update of the forum on another server with the same database, addons, etc. and mails work on this dev-forum. Both Server are paid quality servers, no strange free hosting. Both Server are running with php 5.4.38.

And now we're running out of ideas. Could somebody help us?

Thank you!
We looked into it again, but did not find anything. Does anybody have a hint what we can try? We really ran out of ideas!
Try more debugging:
a) replacing $this->to with a valid Email
b) replacing $this->subject with a valid subject, e.g. 'test'
c) replacing $this->message with a valid message, e.g. 'test'
d) removing trim($this->headers) too

Also, does it happen for all mails or only selective? If selective, which?
Okay, we did a lot of testing the last days. The information about PMs are not sent and the information about a new post in a abo thread are not send too. If you use the "Send Mail"-function, you will get a mail.

We replaced all the things you mentioned but that didn't helped. But the most important thing: We placed a mail()-function in the file that should send a second mail with static subject, message, etc. every time a mail is send:

mail("[email protected]", "Testmail", "This is a test", "[email protected]");

That doesn't work too… It seems that it is impossible to use the mail()-function here. The little test file for the mail()-function from our first post was placed in the mybb-root - and worked. What could be a reason, the mail()-function does not work in the file inc/mailhandlers/php.php? I am no php professional but that seems hard to understand.
(2015-03-06, 08:31 PM)Murray_B Wrote: [ -> ]mail("[email protected]", "Testmail", "This is a test", "[email protected]");

That doesn't work too…

It doesn't work because the 4th argument is incorrect - it's not a valid header. Remove it.
I read you can put just the From-adress into it and it worked (see first post), but we also tried this without the 4th argument, does not change anything.
No, if you want to add the from header, it must be explicit:
mail("[email protected]", "Testmail", "This is a test", "From: [email protected]");
Have a look at http://php.net/mail for more explanations.
Okay, we tried the correct header, but that does not change anything. Are there any rights that could affect this? Maybe something strange in .htaccess?