Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    67
    Thanks
    12
    Thanked 1 Time in 1 Post

    i need help making a form send to two emails

    how do i make this send to 2 emails instead of just 1?
    <?php

    /* SUBJECT AND EMAIL*/

    $emailSubject = 'order';
    $webMaster = 'here-is-email1@example.com';

    /* Gathering Data Variables */
    $company = $_POST['company'];
    $order = $_POST['order'];
    $email = $_POST['Email'];
    $accountnumber = $_POST['1'];


    $body = <<<EOD
    <br>hr<br>
    Email: $email <br>
    Account number: $accountnumber <br>
    Company: $company <br>
    Order: $order <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);

    /*results rendered as HTML */
    $theResult = <<<EOD
    <html>
    <head>
    <title>Submitted</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
    background-color: #000000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #666666;
    text-decoration: none;
    }
    #Layer1 { position:absolute;
    width:112px;
    height:73px;
    z-index:1;
    left: 73px;
    top: 18px;
    }
    .style1 {color: #FFFFFF}
    -->
    </style>
    </head>

    <div id="Layer1"><img src="http://images.thomann.de/pics/herstlogos/gewa.gif" width="154" height="89" alt="Logo" /></div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div>
    <div align="left">
    <p class="style1">Thank you for your order! Your goods will be with you very soon.</p>
    </div>
    </div>
    </body>
    </html>
    EOD;
    echo "$theResult";
    ?>

  • #2
    Regular Coder dan-dan's Avatar
    Join Date
    Aug 2009
    Location
    England
    Posts
    483
    Thanks
    22
    Thanked 79 Times in 78 Posts
    Two to the same address or different addresses?

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    830
    Thanks
    10
    Thanked 79 Times in 77 Posts
    How to submit a form to multiple email addresses: http://webdesign.about.com/b/2008/01...-addresses.htm
    ☠ ☠RON☠ ☠

  • #4
    New Coder
    Join Date
    Apr 2012
    Posts
    67
    Thanks
    12
    Thanked 1 Time in 1 Post
    hi guys thanks but it still doesn't work can any1 try to solve this please, here is the code again
    <?php

    /* SUBJECT AND EMAIL*/

    $emailSubject = 'order';
    $webMaster = 'example@123.com';

    /* Gathering Data Variables */
    $company = $_POST['company'];
    $order = $_POST['order'];
    $email = $_POST['Email'];
    $accountnumber = $_POST['1'];
    $purchaseordernumber = $_POST['2'];


    $body = <<<EOD
    <br><hr><br>
    Email: $email <br>
    Account number: $accountnumber <br>
    Company: $company <br>
    Purchase order number: $purchaseordernumber <br>
    Order: $order <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);

    /*results rendered as HTML */
    $theResult = <<<EOD
    <html>
    <head>
    <title>Submitted</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
    background-color: #000000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #666666;
    text-decoration: none;
    }
    #Layer1 { position:absolute;
    width:112px;
    height:73px;
    z-index:1;
    left: 73px;
    top: 18px;
    }
    .style1 {color: #FFFFFF}
    -->
    </style>
    </head>

    <div id="Layer1"><img src="http://images.thomann.de/pics/herstlogos/gewa.gif" width="154" height="89" alt="Logo" /></div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div>
    <div align="left">
    <p class="style1">Thank you for your order! Your goods will be with you very soon.</p>
    </div>
    </div>
    </body>
    </html>
    EOD;
    echo "$theResult";
    ?>

  • #5
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    What was the problem with the code I posted in your other thread? As I said there, your PHP is not formed correctly to send the mail.

    If you're trying to send two different email messages then you can just add another mail command:

    Code:
    $success = mail($webMaster, $emailSubject, $body, $headers); 
    mail($anotherEmail,$emailSubject,$differentText, $headers);
    Last edited by SB65; 04-10-2012 at 01:43 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •