How to send mail to multiple emails at once with mail() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yorme
    New Member
    • Jan 2011
    • 2

    How to send mail to multiple emails at once with mail() function

    Please, guys. I really need your help with this because i have tried every means i know but all to no avail. Thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you specify additional receivers in the mail headers, i.e. the CC and BCC headers.

    Comment

    • Yorme
      New Member
      • Jan 2011
      • 2

      #3
      Thanks dude. But how do i include d bcc, cc in d function. Write an example for me to see

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        examples how to add headers are given here.

        Comment

        • Niheel
          Recognized Expert Moderator Top Contributor
          • Jul 2005
          • 2432

          #5
          As dormilich pointed out there's a nice example of how to add BCC and CC to your PHP mail code:

          taken from php.net mail fucntion page:

          Code:
          <?php
          // multiple recipients
          $to  = 'aidan@example.com' . ', '; // note the comma
          $to .= 'wez@example.com';
          
          // subject
          $subject = 'Birthday Reminders for August';
          
          // message
          $message = '
          <html>
          <head>
            <title>Birthday Reminders for August</title>
          </head>
          <body>
            <p>Here are the birthdays upcoming in August!</p>
            <table>
              <tr>
                <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
              </tr>
              <tr>
                <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
              </tr>
              <tr>
                <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
              </tr>
            </table>
          </body>
          </html>
          ';
          
          // To send HTML mail, the Content-type header must be set
          $headers  = 'MIME-Version: 1.0' . "\r\n";
          $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
          
          // Additional headers
          $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
          $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
          $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
          $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
          
          // Mail it
          mail($to, $subject, $message, $headers);
          ?>
          niheel @ bytes

          Comment

          Working...