TOPIC:

Mailback custom HTML and Subject - MultiLanguge 1 year 7 months ago #232008

  • Topic Author
  • baggio
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
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

Please Log in or Create an account to join the conversation.

Mailback custom HTML and Subject - MultiLanguge 1 year 7 months ago #232018

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
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

Please Log in or Create an account to join the conversation.

Mailback custom HTML and Subject - MultiLanguge 1 year 7 months ago #232028

  • Topic Author
  • baggio
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
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,

Please Log in or Create an account to join the conversation.

Last edit: Post by baggio.

Mailback custom HTML and Subject - MultiLanguge 1 year 7 months ago #232031

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
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

Please Log in or Create an account to join the conversation.

Mailback custom HTML and Subject - MultiLanguge 1 year 7 months ago #232039

  • Topic Author
  • baggio
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 9
  • Thanks: 0
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

Please Log in or Create an account to join the conversation.

Mailback custom HTML and Subject - MultiLanguge 1 year 7 months ago #232045

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
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

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.053 seconds

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

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!