Forums

How to set To Email in custom code before Sending email ?

ai.bhargav 08 Aug, 2012
Hello All,

I have used 1 chronoform in number of pages(approx. 20), and i have set couple of email address in option Email To under Setup Email tab. all this working great. Thanks to chronoform.

Now i want to different email address only for 1 page.

Can anyone please tell me how can i able to set different email address for specific page ?

it's urgent. Any help will be appreciated.

Thanks in advance...!
Max_admin 08 Aug, 2012
Hi,

The easiest way to do this is to use "Dynamic to" instead, and inject your address into the $form->data array, e.g: use "demail" in the dynamic to and use a cutsom code action before the email:

<?php
$form->data['demail'] = "me@m.com";
?>


You will need to identify the page some how and alter the address above using an "if" statement.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ai.bhargav 09 Aug, 2012
Hi Max,

Thanks for your quick guidance, i have solved it yesterday and forgot to mention here.

I have achieve it with below code :

$currentUrl = $_SERVER["REQUEST_URI"];
if($currentUrl =='http://www.google.com/')  // comparing with page for which i am setting this email
{
$MyForm =& CFChronoForm::getInstance('formname'); 
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); 
$MyFormEmails->setEmailData(1, 'to', 'emailname@domainname.com'); 
}


Thanks once again!
GreyHead 09 Aug, 2012
Hi,

For other readers, Max's reply is for ChronoForms v4; ai.bhargav's code is for CFv3.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger