Both table and emails not working on contact form

simonshah 12 May, 2008
H I there

A couple of problems with ChronoEngine on a Joomla 1.5.2 install on contact form from my site at simonshah.co.uk

I have created the form, customized the look, used validation and created the page redirect but have problems with email not working and data not populating the table.

Looking through the FAQ and forums, I did the following:

EMAIL
Tested email works fine from the site by placing a mailto HTML tag to test and that worked ok (now removed the mailto tag as I only used it for testing)

Tried to complete a form fill with Debug On and Verification Off but couldn’t see any debug messages for the email.

Check my own spam box but nothing came in there

FORM
Used phpmyadmin to delete the existing table jos_chronoforms1 and I deleted the code from the autogenerated tab and recreated the table within Chr0onoforms
Retested the form but still no data population into the table at the back end

Settings on man page of chronoengine are as follows:

Form name: contact_form
Email results? Yes
Email Address: I have put a correct email address here
Email Subject: Contact Form Submission
Form method: Post
Record and Send Users IP: Yes
From Email: I have out a correct email address here
From Name: Simon Shah
IN which format to send the results: Field titles
Debug: on
MYSQL Statement; ENGINE
Enable Mambots: No






Regards
GreyHead 12 May, 2008
Hi simonshah,

Please remove the Redirect URL temporarily to see the DeBug info.

Thanks

Bob
simonshah 13 May, 2008
Got the debug to work now by turning off the redirect and this is the message:

_POST: Array ( [firstname] => Simon [lastname] => Shah [email] => email address [comments] => hello world )
Case 2: Use template
E-mail: 'Yes' custom
Email sent
E-mail message
From: Simon Shah [email address]
To: email address
Subject: Contact Form Submission - Simon Web

Submitted by 89.243.228.75

Reading this information, it all looks correct to me, so unsure next steps..
GreyHead 14 May, 2008
Hi simonshah,

As you say that all looks fine. The 'Email sent' message says that Joomla sent the message off to whatever mailserver you have configured for your site - so the mail problem is somewhere after that. You have the same email in 'to' and 'from' so quite possibly it got dropped in a spam filter somewhere. Try using two different emails here.

It also looks as though there is no body to your email. Do you have anything in the 'Email template' box on the Form HTML tab?

I can't tell anything about the database save from this - what code is in the Autogenerated code tab for this form?

Bob
simonshah 14 May, 2008
Hi Greyhead

Taking your suggests

EMAIL:

I reverted to 'Fields Titles' to format the send email as I didnt actually have a template made up, thinking that might be the problem.

I then used the form to send to my gmail account and received tis debug message:

PHPMAILER_EXECUTE/usr/sbin/sendmail
_POST: Array ( [firstname] => simon [lastname] => shah [email] => email address[comments] => test )
Case 1: Use table layout
E-mail: 'Yes' custom
Email sent
E-mail message
From: Simon Shah [email address]
To: email address
Subject: Contact Form Submission - Simon Web

firstname simon
lastname shah
email email address
comments test

But the email was not received at my gmail account either. I also checked the spam box too

Then I played around with Joomla mail settings, switching and testing between phpmail and sendmail but neither seemed to rectify the problem. Remember that I tested the mail functionality earlier using the mailto command and the email worked (using phpmail setting in Joomla)

The form is up at http://simonshah.co.uk/index.php/component/option,com_chronocontact/Itemid,49/


DATABASE TABLE:
Here is the code in the autogenerated tab:

<?php
$database =& JFactory::getDBO();
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);

$database->setQuery( "INSERT INTO #__chronoforms_1 VALUES (
'' , '".$inum."','". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".JRequest::getVar('firstname','', 'post', 'string', '' )."' , '".JRequest::getVar('lastname','', 'post', 'string', '' )."' , '".JRequest::getVar('email','', 'post', 'string', '' )."' , '".JRequest::getVar('comments','', 'post', 'string', '' )."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>


Many thanks for your advice

Simon
GreyHead 14 May, 2008
Hi Simon,

The "PHPMAILER_EXECUTE/usr/sbin/sendmail" message isn't from ChronoForms it's a site message about a problem with the PHP Mailer . . . It translates into "PHP could not execute /usr/sbin/sendmail"

The database code looks OK _ it may be that the mailer problem is interrupting the code before it gets to that stage.

Bob
simonshah 14 May, 2008
Hi Greyhead

For your check of the autogenerated data I am guessing that the table issue might be a symptom of an email issue.

So about the email, when I revert the Joomla mail setting back to PHPmail instead of Sendmail and test the form I get the following:

_POST: Array ( [firstname] => simon [lastname] => shah [email] => email[comments] => this is a test )
Case 1: Use table layout
E-mail: 'Yes' custom
Email sent
E-mail message
From: Simon Shah [email]
To: email
Subject: Contact Form Submission - Simon Web

firstname simon
lastname shah
email email address
comments this is a test
Submitted by 89.243.228.75

So id doesn't look like an error here and once again I tested that the email works using mailto: command with the setting as PHPMail

Any thoughts on my nest steps?

Thanks again
GreyHead 14 May, 2008
Hi Simon,

Sorry if I'm repeating myself - does email work if you click on an email icon in a Joomla content page? All that CF does is pass the email off to the Joomla mailer. As long as that 'Email sent' message is there it *should* behave exactly the same as using mailto with the same mailer.

Bob
simonshah 14 May, 2008
Hi Greyhead

I contacted the hosting company and they said I needed to follow some instructions to get php mail to work on the server. But not sure how to get it to work in Joomla/Chronoforms.

I created a dedicated email on the hosting account called [email]webcontact@simonshah.co.uk[/email] and forwarded that to my personal talktalk account.

I changed the Joomla mail server settings and also the Chronoforms mail settings (Email Address and From Email) to [email]webcontact@simonshah.co.uk[/email]


Not sure about the next steps and below was the kb article I received from the hosting provider. I think I have to put in some code into the Onsubmit code area of the chrono form but little unsure exactly what I have to put.

Here is the kb article:

Before we startTo prevent spam being sent through our webservers, there are certain conditions that must be met before our SMTP servers will send the email.
1) Email must be sent to, or from, an email address hosted by Fasthosts. An email address hosted by Fasthosts is not the same as a domain name hosted by Fasthosts. If your domain's MX record points to another email provider, it will not count as being hosted by Fasthosts.

2) To stop misuse of your form by third parties the sendmail_from variable should be set to your Fasthosts hosted email address. While access to the php.ini file is restricted on our shared environment, you can sent this variable using the ini_set() command, shown below.

3) A fifth parameter -f should be added to the sendmail function. This will set the name of the from email address.

In its basic form, a simple sendmail script will look like this:

<?php
ini_set("sendmail_from", " [email]user@yourdomain.com[/email] ");
mail($email_to, $email_subject, $email_message, $headers, [email]'-f'user@yourdomain.com[/email]);
?>

Provided that you set the sendmail variable, before attempting to send the email. Specify the from address as a fifth parameter in the sendmail function, and the email is either to, or from, a Fasthosts hosted email address you should have no problems.


ExampleThis example will take the information from a feedback form, send it to you in an email message, then forward the customer to a "thank you for your comments" page. In this example we will use bobsdomain.co.uk as the domain name. There is a mailbox hosted with Fasthosts called [email]bob@bobsdomain.co.uk[/email].
A simple feedback form

First of all we need to create a feedback form that will receive the data. We will call this form feedback.html. In its most basic form, it can look like this:

<form method='post' action='sendmail.php'>
Email address: <input name='email' type='text' /><br />
Name: <input name='name' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>

example feedback form

Not the prettiest form, but it can be tidied up, and validation can be added at a later date. This form has three fields (email address, name and message) that users can fill in. Once the user click the Submit button, it will collect the information contained within the fields, tag the information as "email, name and message", then send the information to sendmail.php.

The sendmail script

Now we have a form that sends information to a script, we need to create a script to send the email. In this example, we will name the script sendmail.php as this is the address the our form is submitting the data. To send an email, we need certain information (variables), so lets set them first.

<?php
ini_set('sendmail_from', $email_from);
$email_to = "bob@bobsdomain.co.uk";
$name =$_POST['name'];
$email_from =$_POST['email'];
$email_subject = "Feedback from website";
$comments = $_POST['message'];
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";

Now lets build the message of the email with the users name and comments.

$message= "Name: ". $name . "\nComments: " . $comments;

Finally, let's send the email. If the email is sent we will go to a thank you page, if there is an error we will display a brief message.

$sent = mail($email_to, $email_subject, $message, $headers, '-f' .$email_from);
if ($sent)
{
header( "Location: http://www.bobsdomain.co.uk/thankyou.html" );
} else {
echo 'There has been an error sending your comments. Please try later.';
}
?>

example sendmailscript form

This script does not have any validation or error checking, so it is not recommended that you copy it directly to your website, however, it does show the basics of sending email from our webservers, and can be used as a framework for your own scripts.

Using third party scripts to send emailThird party scripts using sendmail will also work on Fasthosts servers, although some will need slight changes made in order to work correctly.
If you are using a third party script to send email remember to set the sendmail_from variable (using ini_set('sendmail_from',email_from)), add the fifth -f parameter, and send the email either to, or from, a Fasthosts hosted email address.

Thanks for your patience with me. I am not too technical but trying to be methodical in my approach.
GreyHead 15 May, 2008
Hi simonshah,

Two things here:

a) you must use the approved email address in the From & ReplyTo boxes.

b) It sounds as though you need an extra parameter to the sendmail command. I can't help with this, it's probably possible but a quick Google says that the most common answer is 'change hosts'.

Good luck

Bob
hooperman 09 Apr, 2010
Hi Bob,
I have the same problem as Simon Shah, I am also with Fasthosts. Changing hosts is really not an option for me, as I have many sites with Fasthosts and have recently been implementing Joomla on a number of these. Where can I go to find out more about adding the extra parameter to the sendmail command through Chrono Forms?

Paul
GreyHead 09 Apr, 2010
Hi Paul,

Sorry, I have no more information than in the previous post here.

You can probably add the PHP ini command in the tempalte index.php but I don't know if it will work from there. I guess that you'll need to hack the Joomla core code to add the extra parameter.

Bob
hooperman 09 Apr, 2010
Ok, I'll try and work it out for myself. I'll post the solution if I find one.
This topic is locked and no more replies can be posted.