HI
Sorry to ask what might be a basic question, but im having problems setting up an autoresponder with chronoforms. I have been through the forums and found a previous thread about this, but so far havent been able to utilise the information to make it work!
I have a very simple form eg
Also Im unsure how and where the variables need to be defined. Again from the same post, an admin used the following code
Sorry to ask what might be a basic question, but im having problems setting up an autoresponder with chronoforms. I have been through the forums and found a previous thread about this, but so far havent been able to utilise the information to make it work!
I have a very simple form eg
<style type="text/css">
label {
width:4em;
float:left;
margin-right:.5em;
color:red;
}
fieldset {
border:1px #cccccc solid;
width:50%;
}
</style>
<fieldset>
<p><label for="name">Name</label><input type="text" name="name" id="name" size="40"></p>
<p><label for="email">Email</label><input type="text" name="email" id="email" size="40"></p>
<p><label for="subject">Subject</label><input type="text" name="subject" id="text" size="40"></p>
<p class="submit"><input type="submit" value="submit" /></p>
</fieldset>
When the user submits this information, i want them to receive an acknowledgement that their form has been sent. The previous post on this subject said that this line needed to be used...<?php
mosMail($from, $fromname, $recipient, $subject, $html_message, true,$ccemails, $bccemails, $attachments, $replyto_email, $replyto_name );
?>
Where does this go? I.e. in the on submit code before sending email or the on submit code after sending email. Also Im unsure how and where the variables need to be defined. Again from the same post, an admin used the following code
<?php
$from = $replyto_email ="artistjewel@example.com";
$fromname = $replyto_name = "artistjewel";
$recipient = $_POST['email'];
$subject = "email from artistjewel";
$html_message = "<p>Hi, Here's a message from artistjewel.</p>";
$ccemails = $bccemails = $attachments = "";
mosMail($from, $fromname, $recipient, $subject, $html_message, true, $ccemails, $bccemails, $attachments, $replyto_email, $replyto_name );
?>
But im not sure where this needs to go and what I need to change for my purposes. I would be immensely grateful for any help and advice you can give. Sorry for my distinct lack of php knowledge!!<br><br>Post edited by: GreyHead, at: 2007/12/02 15:15
Hi burlster,
Do you just want to send the 'thank you ' email? Or do you want to send two different emails - one to an admin and the other (with different contents) to the user?
It's only if you want to do the second of these that you need this extra code.
For the two-email scenario you can pick up variables from your form using the '$_POST['field_name']' syntax you see in the code.
The code to send the second email needs to go into the 'after email' box, otherwise it may corrupt the first email.
Bob
Do you just want to send the 'thank you ' email? Or do you want to send two different emails - one to an admin and the other (with different contents) to the user?
It's only if you want to do the second of these that you need this extra code.
For the two-email scenario you can pick up variables from your form using the '$_POST['field_name']' syntax you see in the code.
The code to send the second email needs to go into the 'after email' box, otherwise it may corrupt the first email.
Bob
thanks for getting back to me
I would want the user to submit their details, which would then be emailed to me. At the same time I would want them to receive an email confirming that their issue is being looked into, or thanking them for their information.
so would the code need to look something like this (sorry i know next to nothing about php!)
I have tried this before, but all that it has ended up doing is making the user send me the thank you message. The actual information the user sends appears to get lost<br><br>Post edited by: GreyHead, at: 2007/12/02 15:13
I would want the user to submit their details, which would then be emailed to me. At the same time I would want them to receive an email confirming that their issue is being looked into, or thanking them for their information.
so would the code need to look something like this (sorry i know next to nothing about php!)
<?php
$from ="me@example.com";
$fromname = "admin";
$recipient = $_POST['email'];
$subject = "$_POST['subject'];
$html_message = "<p>Hi, Thank you for contacting me, I will respond as soon as possible.</p>";
mosMail($from, $fromname, $recipient, $subject, $html_message, true, );
?>
I have tried this before, but all that it has ended up doing is making the user send me the thank you message. The actual information the user sends appears to get lost<br><br>Post edited by: GreyHead, at: 2007/12/02 15:13
Hi burlster,
That looks OK to me. It must go in the 'after email' box though or it will replace the data email to you.
Are you receiving the data email OK now (i.e. before this change)?
Bob
That looks OK to me. It must go in the 'after email' box though or it will replace the data email to you.
Are you receiving the data email OK now (i.e. before this change)?
Bob
thanks for getting back to me Greyhead, sorry for the delay in responding.
I have tried using the above php script, all of which is placed in the "after sending" box. The submitted details are being received at the selected email address, but im not seeing the autoresponder message.
Is all the code in the correct place, and is there anything else im missing?
Also, could you explain what the line
actually means??
Thanks
Burlster
Post edited by: burlster, at: 2007/12/06 03:18<br><br>Post edited by: burlster, at: 2007/12/06 04:08
I have tried using the above php script, all of which is placed in the "after sending" box. The submitted details are being received at the selected email address, but im not seeing the autoresponder message.
Is all the code in the correct place, and is there anything else im missing?
Also, could you explain what the line
mosMail($from, $fromname, $recipient, $subject, $html_message, true, );
actually means??
Thanks
Burlster
Post edited by: burlster, at: 2007/12/06 03:18<br><br>Post edited by: burlster, at: 2007/12/06 04:08
Hi burlster,
I've just noticed a spurious " in the earlier code
The mosMail line is a function call to the Joomla mailer, basically it says please send an email where:[list]the from address is taken from the string in $from the from name is taken from the string in $fromaddress and so on [/list], the 'true' says send in html format (though we've seen in another thread that 'false' doesn't seem to set plain text).
Bob
I've just noticed a spurious " in the earlier code
$subject = "$_POST['subject'];
should be$subject = $_POST['subject'];
Sorry I missed that earlier.
The mosMail line is a function call to the Joomla mailer, basically it says please send an email where:[list]
Bob
Once again thanks for your response.
Im slowly getting the hang of this now, and have finally got it to work! Im actually sadly excited about that.:)
Im slowly getting the hang of this now, and have finally got it to work! Im actually sadly excited about that.:)
I've just implemented the same while playing around on my dev machine! If you are using Joomla! 1.5 then the more future proof way of doing this is to use the JMail functions in the API to do it. Here is a commented code snippet:
This is working quite nicely for me. Remember this goes in the On Submit code - after sending email box in Chronoforms!
For more info on the JMail library take a look at: http://api.joomla.org/Joomla-Framework/Utilities/JMail.html
Hope this helps someone else!
Jon.
edit: typo in code.<br><br>Post edited by: jonflgiles, at: 2007/12/10 17:55
<?php
//not strictly necessary depending on the environment you are in but import the library anyway:
jimport('joomla.utilities.mail');
// setup vars for sendinf auto responder to visitor. Uses data from the posted form as follows: $_POST['fieldname']
$auto_body = 'Message goes in here in HTML if you wish and including data from the form.';
//set a var for the subject
$auto_subject = 'Give it a subject name';
//Set a var for the recipient (your site visitor?)
$auto_recipient = $_POST['emailfield'];
//Send the email:
//initiate a new JMail object
$mail = JFactory::getMailer();
//Add the recipient email address here
$mail->addRecipient( $auto_recipient );
//Set Sender and ReplyTo here
$mail->setSender( array( 'email address', 'name' ) );
$mail->addReplyTo( array( 'email address', 'name' ) );
//Set the subject
$mail->setSubject( $auto_subject );
//if you want you email to be sent as HTML with text/html headers use the following line
$mail->IsHTML( '1' );
//Add in the body text
$mail->setBody( $auto_body );
//Send!
$sent = $mail->Send();
//You can test the state of $sent to see if the email was sent correctly here.
?>
This is working quite nicely for me. Remember this goes in the On Submit code - after sending email box in Chronoforms!
For more info on the JMail library take a look at: http://api.joomla.org/Joomla-Framework/Utilities/JMail.html
Hope this helps someone else!
Jon.
edit: typo in code.<br><br>Post edited by: jonflgiles, at: 2007/12/10 17:55
Hi Jon,
Thanks for the breakdown.
This is pretty much what ChronoForms does except that Max has chose to use the slightly simpler Utility interface. The sendmail code for J1.5 is
Bob
Thanks for the breakdown.
This is pretty much what ChronoForms does except that Max has chose to use the slightly simpler Utility interface. The sendmail code for J1.5 is
sendMail(string $from, string $fromname, mixed $recipient, string $subject, string $body, [boolean $mode = 0], [mixed $cc = null], [mixed $bcc = null], [mixed $attachment = null], [mixed $replyto = null], [mixed $replytoname = null])
You can use this directly in the 'OnSubmit after email' box.Bob
Jon,
That info was great, Ive been looking at other posts using mosMail and wondered why it wasn't working. Bob, this Autoresponder should be in the FAQ.
cheers Chaps
That info was great, Ive been looking at other posts using mosMail and wondered why it wasn't working. Bob, this Autoresponder should be in the FAQ.
cheers Chaps
I just came across this thread and tried the code, it worked great, exactly what I was looking for.
I'm not great with PHP, is there any way to echo additional form fields in the $auto_body, for example, a way of echoing the persons name they entered in the form?
I'm not great with PHP, is there any way to echo additional form fields in the $auto_body, for example, a way of echoing the persons name they entered in the form?
Hi highrockmedia,
I think I'm right in saying that you don't need this in the current ChronoForms releases, you can set up many different emails in the Email Setup each with their own config and template.
Bob
I think I'm right in saying that you don't need this in the current ChronoForms releases, you can set up many different emails in the Email Setup each with their own config and template.
Bob
Hi highrockmedia,
I think I'm right in saying that you don't need this in the current ChronoForms releases, you can set up many different emails in the Email Setup each with their own config and template.
Bob
Hi Bob, true, but I tried that method using a "Dynamic To" field in a second email block (which in turn generated a second email template) but could only get one of the email templates to mail.
No doubt I was doing something wrong, Maybe I will post a screen shot of my two email blocks and we can try to work that method out. The method on this page appealed to me because it just worked right off the bat.
Ok, I re-visited the Dynamic To functionality and was able to successfully get two different emails, one sent to the client and one to admin.
This topic is locked and no more replies can be posted.