conditional mailbackfile

  • gcom
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

gcom created the topic: conditional mailbackfile

I have a form where users can sign up to an event that takes place in two cities. The user can coose which event he wants to attend via radio buttons.
After submission of the form I want to send a confirmation mail with a pdf containing additional informations about the event in the city the user has selected before:
If he chooses city A the attached pdf would be a.pdf
if he chooses city B the attached pdf would be b.pdf
How can I accomplish this using BreezingForms?
#230225
  • Posts: 2823
  • Karma: 95
  • Thank you received: 379

mihaela replied the topic: conditional mailbackfile

Hello,

To send attachments in email depending on the radio group selection will require a custom solution since there isn't an option to simply set this.

Here is how to achieve what you want.

You have to go to Advanced options of your form > More options > Submit pieces and in the End Submit section, select Type Custom and there you have to create an email. Here is an example of the code that will do what you want:
$this->execPieceByName('ff_InitLib');
$from = 'your@email.com'; //change to wanted email
$fromname = 'yourname'; //change to wanted from name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
$attachment = [];

$body = '';
foreach ($this->maildata as $data) {
 
  if( $data[_FF_DATA_NAME] == 'radiogroupname'){
   $ischeck =  $data[_FF_DATA_VALUE];
    if (strpos($ischeck, 'groupvalue1') !== false) {
        array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/a.pdf'); }
    if (strpos($ischeck, 'groupvalue2') !== false) {
        array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/b.pdf'); }
  }   

   $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
 
}
$this->sendMail($from, $fromname, 'wantedemail@mail.com', $subject, $body, $attachment);  
You need to make following adjustments so that it fits your form:

1. Replace radiogroupname with the Name of the radio group element.

2. Replace groupvalue1 and groupvalue2 with values of A and B options in radio group.

3. Set the correct paths to the attachments a.jpg and b.jpg .

4. Replace 'wantedemail@mail.com' with the email address that you want to send the email to.

Let me know whether this works as you wanted.
If you have more questions, feel free to ask.

Regards,

Mihaela
#230235
  • Posts: 2823
  • Karma: 95
  • Thank you received: 379

mihaela replied the topic: conditional mailbackfile

Hello,

To send attachments in email depending on the radio group selection will require a custom solution since there isn't an option to simply set this.

Here is how to achieve what you want.

You have to go to Advanced options of your form > More options > Submit pieces and in the End Submit section, select Type Custom and there you have to create an email. Here is an example of the code that will do what you want:
$this->execPieceByName('ff_InitLib');
$from = 'your@email.com'; //change to wanted email
$fromname = 'yourname'; //change to wanted from name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
$attachment = [];

$body = '';
foreach ($this->maildata as $data) {
 
  if( $data[_FF_DATA_NAME] == 'radiogroupname'){
   $ischeck =  $data[_FF_DATA_VALUE];
    if (strpos($ischeck, 'groupvalue1') !== false) {
        array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/a.pdf'); }
    if (strpos($ischeck, 'groupvalue2') !== false) {
        array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/b.pdf'); }
  }   

   $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
 
}
$this->sendMail($from, $fromname, 'wantedemail@mail.com', $subject, $body, $attachment);  
You need to make following adjustments so that it fits your form:

1. Replace radiogroupname with the Name of the radio group element.

2. Replace groupvalue1 and groupvalue2 with values of A and B options in radio group.

3. Set the correct paths to the attachments a.jpg and b.jpg .

4. Replace 'wantedemail@mail.com' with the email address that you want to send the email to.

Let me know whether this works as you wanted.
If you have more questions, feel free to ask.

Regards,

Mihaela
#230236
  • gcom
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

gcom replied the topic: conditional mailbackfile

Hello Mihaela,
thank you very much. I'm glad, this is possible with Breezingforms.
Would this also be possible when I use a custom mailback template? The reason I'm asking for this is that I want to send this as an html formatted email to make it look prettier.
I tried to accomplish this by having the html code in the $body variable but it keeps sending the html code instead of sending html emails
Best Regards
Markus
#230238
  • Posts: 2823
  • Karma: 95
  • Thank you received: 379

mihaela replied the topic: conditional mailbackfile

Hello again,

You can add html code to body of the email in end submit, but you must add an additional $isHtml attribute to the sendmail function and set it to true in order for it to work.
I assume that you haven't set that and that is the reason it didn't work for you.
Here is an example of html email code from End Submit.
$this->execPieceByName('ff_InitLib');
$from = 'test@test.com';
$fromname =  'yourname';
$subject = 'mysubject';

$recipient = 'myemail@gmail.com'; 

$name= ff_getSubmit('name');
$email= ff_getSubmit('email');

$attachment=null;
$isHtml = true;

$body =  "
<html><body>

<h1>This is the title of email </h1>

<table style='color:blue;'>
<tr>
<td>
   <strong>Name:</strong>
</td>
<td>
   $name
</td>
</tr>

<tr>
<td>
   <strong>Email:</strong>
</td>
<td>
   $email
</td>
</tr>
</table>
</body></html>";

$this->sendMail($from, $fromname, $recipient, $subject, $body, $attachment, $isHtml); 

Let me know whether this solved the html code issue.
If you have more questions, feel free to ask.

Regards,

Mihaela
#230240
  • Posts: 12
  • Thank you received: 0

zmand13 replied the topic: conditional mailbackfile

Hi,

I am not sure whether my question fits to this topic but it looks similar.
What I want to achieve is to create a Mailback email depending on the Value of the radiobuttons.
I tried to insert a simple php IF statement in the html code window of the mailback message but after saving the message the code was removed by the system.

My questions are:
1. can conditional mailback be done this way, by including php code in the html code window?
2. if yes, how this code should look like not to be removed by the system?
3. if not, how it can be done?

Thank you very much in advance.

Best,

Zoran
#231040
Moderators: ForumSupporttomeperica
Time to create page: 0.043 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription 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 for just 49! (Summer Sale)

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the 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