Jump to content

Single Form, Multiple Emails?


Go to solution Solved by TOA,

Recommended Posts

Hi Guys,

 

Newbie here, I have a working admin system built and just finishing a few things off.

 

I have a form with a few input fields (make, model, name) and one tick box 'Do you need assistance?'.

 

Once submitted, this form successfully sends the info via email to manager@something.com. However, when the tick box mentioned above is ticked, Id like it to ALSO send a different email to assistance@something.com

 

Code below;

if(sendQf22Email($make, $model, $name,)){
$boolMailSent = true;
}else{
$boolMailSent = false;
}
         echo "<h1>Request Submitted</h1>
             <p>Your request has been submitted and is queued for processing.</p>
             <p>We will contact you once completed.</p>
            ";

Basically the secondary email should go to an 'Assistance' team. However the main email should always go to the Manager.

 

The second email would say something like 'Dear assistance team, please see form below as assistance has been requested......'

 

Is this possible?

 

Apologies if this sounds confusing.

 

And thanks in advance.

 

J

 

Link to comment
https://forums.phpfreaks.com/topic/280922-single-form-multiple-emails/
Share on other sites

From the manual

 

 

user@example.com, anotheruser@example.com

 

 

Just add a conditional that only adds it if your box is ticked.

*Edit - after reading the whole post again (:P) you'll need to just make a second mail call to use a different message, but the conditional part would remain the same - if it's ticked, run a second call to mail().

Edited by TOA
  • Solution

// here's your normal mail call to manager

mail($manager_email, $manager_message);

 

// here's your conditional call

if (isset($_POST['checkbox_name'])) {

  mail($assistance_email, $assistance_message);

}

 

You just need to see if the checkbox is checked and if it is send another email. That's what I meant. Sorry, I'm  having a hard time being clear today :)

Thanks for this help TOA, how do I check if the checkbox is checked exactly?

 

The code I have now is as follows

// conditional call
        if (isset($_POST["assistance_reqd_for_setup"])) {
        $mail2($GLOBALS["MyEmail"], $HTMLmessage2);
        }

assistance_reqd_for_setup - is the name of the checkbox

MyEmail - is my email address saved in a global config file

HTMLmessage2 - is the separate email that I'd like to send
 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.