Hi,
I think there is something wrong in the emails.php file of ChronoForms V3.2
Below the incorrect piece of code in emails.php for sending an email when submitting a form:
According to this article:
http://www.packtpub.com/article/session-and-user-with-joomla-1.5-part2
So I think the 2 "if" statements are not working properly. These 2 lines assume that JUtility::sendMail() return values are either true of false. Which obviously is not the case.
I started to notice this when I had debug on and tested a form with email on a local pc. There is no way an email can be sent from this local machine but after submitting the form the debug message kept telling me:
As soon as I replaced the 2 "if" lines in emails.php with this:
I started receiving the correct debug message:
The ChronoForms debug option should make our lives easier. However this way it creates confusion.
Please note this issue doesn't affect the actual sending of an email.
I've searched throught the forums but I am unable to find anything on this topic.
I simply cannot believe I'm the first person who stumbled upon this ...
Something else. Can I do the same email result check in the "On Submit code - after sending email:" box ?
eg:
PolderGuy
I think there is something wrong in the emails.php file of ChronoForms V3.2
Below the incorrect piece of code in emails.php for sending an email when submitting a form:
/**
* Send the email(s)
*/
$email_sent = JUtility::sendMail($from, $fromname, $recipients, $subject, $email_body, $mode, $ccemails, $bccemails, $this_attachments, $replyto_email, $replyto_name );
if ($email_sent)$MyForm->addDebugMsg('An email has been SENT successfully from ('.$fromname.')'.$from.' to '.implode(',', $recipients));
if (!$email_sent)$MyForm->addDebugMsg('An email has failed to be sent from ('.$fromname.')'.$from.' to '.implode(',', $recipients));
According to this article:
http://www.packtpub.com/article/session-and-user-with-joomla-1.5-part2
Notice that we check THE MIXED RETURN value of JUtility::sendMail() to check if the email was sent
successfully. The return value will always be TRUE on success and a JException OBJECT on failure.
So I think the 2 "if" statements are not working properly. These 2 lines assume that JUtility::sendMail() return values are either true of false. Which obviously is not the case.
I started to notice this when I had debug on and tested a form with email on a local pc. There is no way an email can be sent from this local machine but after submitting the form the debug message kept telling me:
An email has been SENT successfully from (me)polderguy@xxxx.com to [email]anonymous@yyyy.com[/email]
As soon as I replaced the 2 "if" lines in emails.php with this:
if ($email_sent !== true) {
$MyForm->addDebugMsg('An email has failed to be sent from ('.$fromname.')'.$from.' to '.implode(',', $recipients));
}
else {
$MyForm->addDebugMsg('An email has been SENT successfully from ('.$fromname.')'.$from.' to '.implode(',', $recipients));
}
I started receiving the correct debug message:
An email has failed to be sent from (me)polderguy@xxxx.com to [email]anonymous@yyyy.com[/email]
The ChronoForms debug option should make our lives easier. However this way it creates confusion.
Please note this issue doesn't affect the actual sending of an email.
I've searched throught the forums but I am unable to find anything on this topic.
I simply cannot believe I'm the first person who stumbled upon this ...
Something else. Can I do the same email result check in the "On Submit code - after sending email:" box ?
eg:
<?php
if ($email_sent !== true) {
echo 'An email has failed to be sent';
}
else {
echo 'An email has been SENT successfully';
}
?>
PolderGuy