Mailback custom HTML and Subject - MultiLanguge

  • baggio
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0

baggio created the topic: Mailback custom HTML and Subject - MultiLanguge

Dear Team,

your multilanguage function in my case is working fine except for the mailback.
When I access "form options > mailback" I can't find any fields where I can customize the content basing upon a specific language.

I found a couple of similar topics but the related solutions were not working for me.

My objectives are:
1) Customize the mailback custom message in another language, adding also language related field values (e.g. Dear {Name:value})
2) Customize the email subject in another language

I purchased the extension around March 2018,

thanks,

Baggio
#232008
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello,

Here is a possible solution to send mailback email with different content basing on language.

Go to form's properties > Advanced tab > More options > Submit Pieces > End Submit , set Type to Custom and paste this code in the framework:
$this->execPieceByName('ff_InitLib');
$lang = JFactory::getLanguage();
$lang_tag = $lang->getTag();
$from = 'Email@OfYourSite.com'; //Change to the sites Email address
$fromname = 'YourSitesName'; //Change to your Sites name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
// you can define here $sumject1, $subject2 and $subject3 to have different subject for // each language

$recipient = ff_getSubmit('emailfieldname');  //replace emailfieldname with the Name of the field where user enters his email address

//Create your own body for each possible option
$body1 = 'English Version';

$body2 = 'German Version';

$body3 = 'French Version';

//Add form values to the custom email content
foreach ($this->maildata as $data) {
   $body1 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
   $body2 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
   $body3 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}

if ($lang_tag == 'en-GB') {
$this->sendMail($from, $fromname, $recipient, $subject, $body1, $mode=1, $attachment);
}
if ($lang_tag == 'de-DE') {
$this->sendMail($from, $fromname, $recipient, $subject, $body2, $mode=1, $attachment);
}
if ($lang_tag == 'fr-FR') {
$this->sendMail($from, $fromname, $recipient, $subject, $body3, $mode=1, $attachment);
}

NOTE: In variables $body1, $body2 and $body3 you define content of the email depending on the language.

Let me know whether this helped and whether you've managed to set this for your form.

Regards,

Mihaela
#232018
  • baggio
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0

baggio replied the topic: Mailback custom HTML and Subject - MultiLanguge

Dear Mihaela,

thank you.
I've added your code, but it doesn't work for me.
For example for the english language I edit the body1 as follow:

$body1 = '

<p>Dear {Nome:value},</p>
<p>Thanks for contacting me.</p>
<p>I will reply to your message in the next 48 hours, </p>
<p>Best Regards,</p>
<p>My name</p>
<p><img src="images/logo-color.svg" /></p>
<p>*********************************</p>
<p>Your message: {Message:value}</p>

';

But I keep to receive the email in the first language (italian)

thanks,
#232028
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello again,

The email that you have created depending on language will be sent to
$recipient = ff_getSubmit('emailfieldname');
That means that the email will be sent to the email address that you inter in emailfieldname textfield element in your form.

You can turn off the Mail notification(s) in Form's Properties while testing this so the default email that is sent form there doesn't confuse you.

Please test it once more and let me know the result. Also, test it from frontend.
If it doesn't work, please send me the whole code from End Submit so I can see whether the code is properly written.

Regards,

Mihaela
#232031
  • baggio
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0

baggio replied the topic: Mailback custom HTML and Subject - MultiLanguge

Dear,

not working at all. I'm testing it from another email (like a submitter user), but I still receive the italian version of the email, instead of the en-GB.

Here the code I added at the location you suggested.

********* START CODE **************

$this->execPieceByName('ff_InitLib');
$lang = JFactory::getLanguage();
$lang_tag = $lang->getTag();
$from = 'Email@OfYourSite.com'; //Change to the sites Email address
$fromname = 'YourSitesName'; //Change to your Sites name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
// you can define here $sumject1, $subject2 and $subject3 to have different subject for // each language

$recipient = ff_getSubmit('email'); //replace emailfieldname with the Name of the field where user enters his email address

//Create your own body for each possible option
$body1 = '

<p>Dear {Nome:value},</p>
<p>Thanks for contacting me.</p>
<p>I will reply to your message in the next 48 hours, </p>
<p>Best Regards,</p>
<p><img src="images/logo-color.svg" /></p>
<p>*********************************</p>
<p>Your message: {Message:value}</p>

';

$body2 = 'German Version';

$body3 = 'French Version';

//Add form values to the custom email content
foreach ($this->maildata as $data) {
$body1 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
$body2 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
$body3 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}

if ($lang_tag == 'en-GB') {
$this->sendMail($from, $fromname, $recipient, $subject, $body1, $mode=1, $attachment);
}
if ($lang_tag == 'de-DE') {
$this->sendMail($from, $fromname, $recipient, $subject, $body2, $mode=1, $attachment);
}
if ($lang_tag == 'fr-FR') {
$this->sendMail($from, $fromname, $recipient, $subject, $body3, $mode=1, $attachment);
}

********* END CODE **************

What I miss? Can you give me a sample code that will work?
Thanks
#232039
  • Posts: 1465
  • Karma: 48
  • Thank you received: 194

mihaela replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello,

I've tested your code on my example and it was working properly.

The only error I saw is that you were creating a html email and you didn't have $isHtml set to true in sendmail() function.

Therefore you should use function like this:
$this->sendMail($from, $fromname, $recipient, $subject, $body1, $attachment, $isHtml); 

Here is the whole code when using HTML code for body:
$this->execPieceByName('ff_InitLib');
$lang = JFactory::getLanguage();
$lang_tag = $lang->getTag();
$from = 'Email@OfYourSite.com'; //Change to the sites Email address
$fromname = 'YourSitesName'; //Change to your Sites name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
// you can define here $sumject1, $subject2 and $subject3 to have different subject for // each language

$recipient = ff_getSubmit('email');

$body1 = '<html><body>
<p>Dear {Nome:value},</p>
<p>Thanks for contacting me.</p>
<p>I will reply to your message in the next 48 hours, </p>
<p>Best Regards,</p>
<p><img src="images/logo-color.svg" /></p>
<p>*********************************</p>
<p>Your message: {Message:value}</p>
';

$body2 = 'German Version';
$body3 = 'French Version';
//Add form values to the custom email content
foreach ($this->maildata as $data) {
$body1 .= '<br>' . $data[_FF_DATA_TITLE].': '.$data[_FF_DATA_VALUE]. '<br>';
$body2 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
$body3 .= "\r\n" . $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}

$body1 .='</body></html>';

if ($lang_tag == 'en-GB') {
$isHtml = true;
$this->sendMail($from, $fromname, $recipient, $subject, $body1, $attachment, $isHtml); 
}
if ($lang_tag == 'de-DE') {
$this->sendMail($from, $fromname, $recipient, $subject, $body2, $mode=1, $attachment);
}
if ($lang_tag == 'fr-FR') {
$this->sendMail($from, $fromname, $recipient, $subject, $body3, $mode=1, $attachment);
}

You wrote "but I still receive the italian version of the email, instead of the en-GB.".

So when you submit the form from frontend you get italian message even though you were submitting from your site being set to another language (en)?

Regards,

Mihaela
#232045
Moderators: ForumSupporttomeperica
Time to create page: 0.077 seconds

New Support System

Dear Customers,

Users with active subscription have support priority which will be dona via ServiceDesk (My Account > Raise a ticket).
FREE Support topics will be answered when AND if there is time.

You can check support guidelines here : here

Regards,
Crosstec Team

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here