TOPIC:

Include multiple emails in a select from list 8 years 5 months ago #66506

  • Topic Author
  • richpig
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 63
  • Thanks: 0
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

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

Re: Include multiple emails in a select from list 8 years 5 months ago #66597

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9229
  • Karma: 167
  • Thanks: 743
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

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

Re: Include multiple emails in a select from list 8 years 5 months ago #67065

  • Topic Author
  • richpig
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 63
  • Thanks: 0
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

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

Re: Include multiple emails in a select from list 8 years 5 months ago #67126

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Developer
  • Developer
  • Posts: 9229
  • Karma: 167
  • Thanks: 743
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

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

Re: Include multiple emails in a select from list 8 years 5 months ago #67173

  • Topic Author
  • richpig
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 63
  • Thanks: 0
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

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

Last edit: Post by richpig.

Re: Include multiple emails in a select from list 8 years 3 weeks ago #75663

  • bgibsonok
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 13
  • Thanks: 0
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!

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

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.051 seconds

Summer Sale!

Massive discounts on all subscriptions!

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!