Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End One submit button, two recipients

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24783
    savage
    Member

    Hi all –

    I took the simpleform from the site and have modified it a bit to allow the user to choose who receives the email.
    I also wanted to add a ‘CC’ if possible.

    Here is the code:

    Code:
    “;
    exit;
    }

    // prepare email body text
    $Body = “”;
    $Body .= “Name: “;
    $Body .= $Name;
    $Body .= “n”;
    $Body .= “Tel: “;
    $Body .= $Tel;
    $Body .= “n”;
    $Body .= “Email: “;
    $Body .= $Email;
    $Body .= “n”;
    $Body .= “Message: “;
    $Body .= $Message;
    $Body .= “n”;

    // send email
    $success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“);

    // redirect to success page
    if ($success){
    print ““;
    }
    else{
    print ““;
    }
    ?>

    I added this little snippet as i thought it may send the second email, but it didn’t work.

    Code:
    $EmailCc = “[email protected]”;

    Maybe I should just modify the ‘$EmailTo’ variable, but i’m not too proficient in php.

    #57111
    savage
    Member
    Code:
    $EmailTo = “[email protected], “.Trim(stripslashes($_POST[‘Recipient’]));
    #57481
    ikthius
    Member

    if you want to carbon copy just do this:

    Code:
    $success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“);

    // redirect to success page
    if ($success){
    //copy to someone else
    mail([email protected], $Subject, $Body, “From: <$EmailFrom>“);
    print ““;
    }

    #57482
    AshtonSanders
    Participant

    All you need to do is pass the CC in the last variable of mail();

    Code:

    Enjoy,

    #57483
    AshtonSanders
    Participant

    Sorry about the double post, but I forgot to mention.

    It’s good practice to always send the email from the domain that your server is on and use a replyto instead.

    Code:
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.