Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

No error when mail server not running?

11 years 7 months ago - 11 years 7 months ago #12234 by inizen
Hi there:

Almost there with AjaxContact, but I noticed that when I stopped my email server AjaxContact still happily told me "Thank you, your message has been sent. We will be getting back to you shortly.". My little test.php script detects an error.

Any idea what is going on? Does AjaxContact check for error returns from PHP Mailer? Looking at ajax.php it seems that $sent is largely ignored (inside the loop through admin email addresses and subsequently). Maybe I've misunderstood but this seems a serious problem, since I'm telling customers I'll get back to them, but won't if I don't get the email. BTW: does AjaxContact store new contacts in a text file or database just in case?

<?php
$to = "test1@local.blah.co.uk";
$headers = "From: info@blah.co.uk";
if( mail( $to , 'This is a test message.' , 'Is this working?' , $headers) ) {
echo 'Email sent.';
} else {
echo 'Email failed to send.';
}
?>

Regards,

Martin

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12236 by douglas
Dear Martin,

Ajax Contact only checks the PHPMailer result for the form recipient email, in other words it ignores the $sent variable for the copy messages;

I have just tested and PHPMailer's Send method is returning true even if I enter e wrong SMTP configuration;

EDIT: in your example you are using the PHP mail function which is not the same as the PHPMailer class;

I'll investigate this a bit further.

Best regards,

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12237 by douglas
Dear Martin,

I still could not find the problem with the PHPMailer, it is always setting to true; Have you tested with PHPMailer? Please do not get confused with the PHP mail function;

I have sent you a few changes to ajax.php, in order to check for each email whether it was sent or not;

Best regards,

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12251 by inizen
Hi Douglas:

I knocked together a noddy PHPMailer test script (attached). This works just fine when my local SMTP server (XAMPP/Mercury) is running, but throws some sort of exception when it is stopped (see below). Note that it does not even to get to check the Sent() return. So not sure how your ajax.php is working. Perhaps something to do with how the error reporting level is set?

Regardless, the error handling in ajax.php seems highly suspect to me. In the 'foreach ($adminMail as $value)' loop, if there were multiple email addresses, the $sent variable is set to false on a failed send, but the loop continues and that value could then be overwritten on the next iteration? Shouldn't the loop immediately abort? Then in the copy message section you overwrite $sent again? Ditto for the carbon copy.

I think you need to beef up the error handling. A contact component that happily tells the contacter that the company will get back to them, but never does (because there is no email) is going to upset the contacter ... which is hardly the point.

I also think you should remove the code that forwards JSON diagnostics to you. I know you are trying to be helpful but are you not receiving contact details that are private to the companies using your component?

Regards,

Martin

----

12345
jos-Error: Application Instantiation Error

JMail -> Send() @ C:\xampp\htdocs\joomla25\test2.php:35
JError :: raiseNotice() @ C:\xampp\htdocs\joomla25\libraries\joomla\mail\mail.php:86
JError :: raise() @ C:\xampp\htdocs\joomla25\libraries\joomla\error\error.php:300
JError :: throwError() @ C:\xampp\htdocs\joomla25\libraries\joomla\error\error.php:176
call_user_func_array() @ C:\xampp\htdocs\joomla25\libraries\joomla\error\error.php:214
JError :: handleMessage()
JFactory :: getApplication() @ C:\xampp\htdocs\joomla25\libraries\joomla\error\error.php:705
JError :: raiseError() @ C:\xampp\htdocs\joomla25\libraries\joomla\factory.php:99
JError :: raise() @ C:\xampp\htdocs\joomla25\libraries\joomla\error\error.php:251

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12252 by douglas
Dear Martin,

1. There was no script attached. Did you zip it first?
Have you tested Joomla core contact component? Does it return errors?

2. I do not break the looping because I think it is better to get one email than none in case of errors; but it should throw the error either way;

3. I'm working on this, however I'm having a hard time to understand why this is happening. I have just tested Joomla core contact component and it also returns a false "thank you" message;

4. I have removed the copy to me in case of errors, actually I don't get any emails from this script from other sites, that's why I did not bother;

I'll send you a new file with the most recent changes in a couple minutes;

Best regards,

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12253 by inizen
Hi Douglas:

1. Nope, I didn't ZIP it. Here it is zipped.

2. But if a subsequent loop iteration succeeds the $sent variable is overwritten and the script forgets it ever encountered an error. That can't be desired behaviour.

3. On my Joomla system (XAMPP based on localhost) registering a new user with my local SMTP server not running results in a 'Could not instantiate mail function.' error at the top of the user management page. Classic PHP mail() behaviour.

4. Thx.

Regards,

Martin

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12255 by douglas
Dear Martin,

1. When I ran your test script I always got "1-maximum-2345Mail sent" no matter the which mailer was set in Joomla global config; (after I have changed the recipient and sender info);

2. In the last file I have sent to you it was already changed and even earlier it would only set $sent to true in the foreach if $mail->Send() returned something other than true;

3. I've been testing in my Linux box with the mail server down and I still do not get this error message when Mailer is set to PHP Mail;
I've created a new user and I did not get the email nor an error. I'm using Joomla 2.5.6; Which Joomla version are you using?
Can you test with Joomla core contact component as well?

Best regards,

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12259 by inizen
Hi Douglas:

I think I've found the problem (although I'm not a PHP programmer). Check out my updated test script (attached). If you switch the checking line from 'if ( $send !== true ) {' to 'if ( $send != true ) {' with your SMTP server not running then the former correctly returns an unable to instantiate mail error, the latter blithely reports success. I think it's to do with != being inequality after type juggling (so it thinks a non-null exception actually equates to boolean true). The former !== operator requires equality and same type, i.e. boolean.

Your code needs to be using === and !== operators when testing the mixed return from send(). Ditto for wherever else you are testing mixed returns.

If this solves the problem then please can you tidy up the error handling (i'm still not convinced by the logic) and send me a new version.

Thanks,

Martin

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12260 by douglas
Dear martin,

That's actually not the case because $mailer->Send() is actually not returning any error;

If you notice the code in the last ajax.php now it is checking if(!($sent instanceof Exception)) because in case there is an error it should be an instance of Exception;

Which Joomla version are you using?
Can you test with Joomla core contact component as well?

Best regards,

Please Log in or Create an account to join the conversation.

11 years 7 months ago - 11 years 7 months ago #12270 by inizen
Douglas,

I've run out of time. Not sure what is wrong with your dev server (if something is wrong) but you need to clean up your code and especially the error handling. Please find attached a hacked version of your ajax.php that is sufficient for my requirements. It reports problems with the underlying mail system.

Another problem with your code is that enabling your multi-captcha plugin breaks the built in contact manager, which throws 'wrong validation code' errors originating from your plugin, which should not even be involved. Disable your plugin, the built in contact manager works fine (and reports errors from the underlying email system).

Software is 80% error handling. You'd have a much better product if you devoted more time and thought to handling errors.

Regards,

Martin

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

11 years 7 months ago #12272 by douglas
Dear Martin,

I'm sorry about the inconvenience.

I've been investigating this a bit further and I got it to work; I have sent a new package to your email;

I was testing with a wrong port and in my local server it only returned an error if the username or password was wrong, that's why I could not find the problem earlier;

Best regards,

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback