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