Include multiple emails in a select from list

  • richpig
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 63
  • Thank you received: 0

richpig created the topic: Include multiple emails in a select from list

Hi

I have a form using a Select from list element, this lists various departments. When someone chooses a department I want the resulting email to go to multiple people per department.

I've tried adding two email addresses to the value, e.g. 0;Department1;email1,email2 but this doesn't work.

Is this possible and if so is there a different separator? Have also tried ; but this removes this department from the form?

Hope someone can help!

Thanks

Rich
#66506
  • Posts: 7464
  • Karma: 150
  • Thank you received: 553

TheMuffinMan replied the topic: Re: Include multiple emails in a select from list

Hi,

I think for this it is better to do some grouping in an end submit piece.

Please go to form => advanced => more options => submit pieces => end submit => click "custom" and enter this into the codebox (code needs adjustments by you):
$this->execPieceByName('ff_InitLib');

// here you define the groups
$group1 = array('email1@email.com', 'email2@email.com' );
$group2 = array('email3@email.com', 'email4@email.com', 'email4@email.com' );

// replace NAME-OF-SELECTION with the name of the select-list (not title)
$selected_group = ff_getSubmit("NAME-OF-SELECTION"); // assuming possible values: group1, group2

$mailing_group = array();

// here the selected group will be assigned (assuming group1 and group2 as possible values from the select-list
switch( $selected_group ){
   case 'group1': $mailing_group = $group1; break;
   case 'group2': $mailing_group = $group2; break;
}

// ok mailing group is determined, now let's send them a copy of the submission

$fromname = 'Your Website name'; // Change to your sender's name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
$recipient = 'your@email.com'; // Change to your admin Email address, will be sent to the email given in addition to the group defined above

$body = '';

foreach ($this->maildata as $data) {
   $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}

$this->sendMail($from, $fromname, $mailing_group, $subject, $body);  // This line actually emails the form.

This code will select the right email addresses and sends them an email. Advantage is that it doesn't reveal emails in the frontend view of the form.

Hope this helps!

Regards,
Markus

===============================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#66597
  • richpig
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 63
  • Thank you received: 0

richpig replied the topic: Re: Include multiple emails in a select from list

Hi Marcus

Thank you for this, its very almost there!

One question for you, is there anyway to make the email that it sends use the custom email template ? I presume something in here needs changing but I am not sure what...


$body = '';

foreach ($this->maildata as $data) {
$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}

I've tried adding my custom layout in the $body = ' '; area but it still includes the default mail contents.

I hope this is an easy one for you

Thanks again anyway

Rich
#67065
  • Posts: 7464
  • Karma: 150
  • Thank you received: 553

TheMuffinMan replied the topic: Re: Include multiple emails in a select from list

Hi,

if you place it just like in the $body, the html will be empty and the field values being displayed below. Can you please post your template code?

Regards,
Markus

===============================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
===============================================
Satisfied?
Consider a membership!
===============================================
Like us on Facebook
===============================================
#67126
  • richpig
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 63
  • Thank you received: 0

richpig replied the topic: Re: Include multiple emails in a select from list

Hi Markus

This is my custom template (html)

<p>The following is a query submitted from the website:</p>

<p><strong>Reference</strong><br />
{typehidden:value}</p>
<p><strong>From</strong><br />
{name:value}</p>
<p><strong>Email</strong><br />
{email:value}</p>
<p><strong>{phone:label}</strong><br />
{phone:value}</p>
<p><strong>Their enquiry is...</strong><br />
{query:value}</p>

Thanks
#67173
  • Posts: 13
  • Thank you received: 0

bgibsonok replied the topic: Re: Include multiple emails in a select from list

Hey Guys,

I have been trying to do something similar forever and I was super stoked to come across this post!

I am needing to do the same thing, we use the email templates to create internal forms and end up with lengthy PHP statements. I have a form due in the next couple of days where I could really use this answer, if there is any way you guys could help me out I would be super grateful.

Thank you so much!
#75663
Moderators: ForumSupporttomeperica
Time to create page: 0.070 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