Recently I've tried to use your (excellent) script on a shared hosting environment different than the one I normally use.
Each time, I encounter the same error message, namely:
"Error: it was not possible to send e-mail message"
I suspected there might be a problem with the PHP mail() function on this hosting, but then I tried this small script with success:
$hostname = "domainname.com";
$from = "email@example.com";
$to = "firstname.lastname@example.org";
$subject = "Test script from $hostname";
$message = "This is a message body for your e-mail";
mail($to,$subject,$message,$from) or die("Mail failed.");
die("Mail sent $from to $to");
As you can see here http://www.work4stars.com/test_email_message.php, the test script from the MIME package also throws the error above.
Please find information on my PHP settings here: http://www.work4stars.com/info.php
Could you please have a look what might be the problem here? I've never encountered this error on any of the other hosting environments I've used thusfar.
Thanks in advance.
|2012-03-06 18:14:19 - In reply to message 1 from Maarten Machiels|
|Does anyone have an idea what might be the problem? Assistance would be appreciated! Thanks in advance.|
|2012-03-06 22:18:53 - In reply to message 1 from Maarten Machiels|
|Were you setting the Return-Path address? Could it be that in that hosting environment the mail function is not allowed to set extra parameters in the 5th argument?|
|2012-03-07 09:14:29 - In reply to message 3 from Manuel Lemos|
|Thank you for your response.|
I've tried commenting out the lines that define the Return-Path. However, even without the Return-Path, the script throws the same error.
Please note that the script test_smtp_message.php does work as expected (e-mail arrives).
What else could be the issue?
|2012-03-07 10:39:11 - In reply to message 4 from Maarten Machiels|
|It is hard to tell. Can you remove the @ symbol from the mail() call and see if PHP displays an error on the page or in the error log if you have one?|
|2012-03-07 11:01:18 - In reply to message 5 from Manuel Lemos|
|I've removed the @ in your scripts and set error_reporting to E_ALL, but no specific error other than "Error: it was not possible to send e-mail message" is given.|
I'm trying to use the SMTP version as an alternative, but am encountering problems with the HTML part. The headers, the text part and the html parts are all outputted literally in the message body.
Could these things be connected? Or am I not doing something right in the SMTP version?
|2012-03-08 09:25:57 - In reply to message 6 from Maarten Machiels|
|I've finally managed to get the script up and running using SMTP. The hosting company also has no clue why the mail() script fails. |
So my problem is solved for now.
P.S.: If you could remove the references to the test files on the websites I mentioned here, I would appreciate it (I cannot remove them myself). The files are gone anyway. Thanks in advance.
|2012-03-11 05:35:08 - In reply to message 7 from Maarten Machiels|
|If you have PHP error log enabled and the mail function fails you are able to know what is the error by looking at the error log.|
Also if you have the option track_errors is set in php.ini or otherwise set it using ini_set('track_errors', 1); before calling the class Send() function, it will be able to return a more complete error message by using the $php_errormsg variable.
|2012-03-13 09:58:47 - In reply to message 8 from Manuel Lemos|
|The setting log_errors was always on, but the logs seem to be empty.|
I've managed to work around the issue by using SMTP, this solved it for now.
My control over this shared hosting is very limited, so debugging will be a pain. If I run into the same problem on my normal setup, I will let you know and we can figure it out.