SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    752
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Question PHP mail Multiple BCC:

    Hi

    The PHP manual does not tell me anything about it so I thought this is the best place to ask.

    Does the PHP Mail function allow multiple recipent either in TO or CC or BCC separated by comma?

    For example


    Code PHP:
    <?php
    mail('nobody@example.com,me@myserver.com,you@gmail.com,sam@email.com', 'the subject', 'the message', null,
       '-fwebmaster@example.com');
    ?>

    OR

    Code PHP:
    <?php
     
    $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: [email]birthdayarchive@example.com[/email]' . "\r\n";
    $headers .= 'Bcc: [email]birthdaycheck@example.com,me@myserver.com,you@gmail.com,sam@email.com[/email]' . "\r\n";
     
    // Mail it
    mail($to, $subject, $message, $headers);
    ?>
     
     
    Thanks for your input.

  2. #2
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes it does seperated by a comma.

    PHP Code:
    $toaddress 'email1@123.com,email2@123.com,'.$email3

  3. #3
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    752
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    for some reason, it does not work for me...

  4. #4
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've not seen you full code, but below is a working sample that you can use or customize to your needs.

    PHP Code:
    <html>
    <head>
    <title></title>
    <style type="text/css">
    <!--
    .row1{
        font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
        font-size:11px;
        font-type:normal;
        padding:2px;
        background-color:#E6E6E6;}
    .row2{
        font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
        font-size:11px;
        font-type:normal;
        padding:2px;
        background-color: #F2F2F2;}
    -->
    </style>
    </head>
    <body>
    <?php

    //check that variables filled
    if(isset($_POST['submit']))
        {

        
    //request type
        
    $test trim($_POST['test']);
        
    $test2 trim($_POST['test2']);
        
    $test3 trim($_POST['test3']);
                    


    $recipient2=$email;
    $toaddress 'email_1@123.com,email_2@123.com';


    $subject 'subject: ';
    $mailcontent 'test: '.$test."\n"
                   
    .'test2: '.$test2."\n"
                   
    .'Wtest3: '.$test3."\n";
                   



    $fromaddress  "From: 123@123.com,\r\n";
    $fromaddress  .="BCC: 123@123.com,1235@123.com\r\n";
    //prototype is mail(string to, string subject, string message, string additional_headers, string additional_parameters)
    mail($toaddress$subject$mailcontent$fromaddress);


    if(!
    mail)
        {
            echo
    '<table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr align="center">
                <td colspan="1" align="left">
                <img src="mpsgi.gif" border="0"></td>
                <tr />
                <td>
                <font size="6">Email Form</font>
                </td>
                <tr />
                <td>&nbsp;</td>
                <tr />
                <td>There was a problem sending your email: </td>
                </table>'
    ;
            exit;
        }
        else
        {
        
        echo
    '<table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr align="center">
                <td colspan="1" align="left">
                <img src="mpsgi.gif" border="0"></td>
                <tr />
                <td>
                <font size="6">Change Control Form</font>
                </td>
                <tr />
                <td>&nbsp;</td>
                <tr />
                <td>Thank you for email.</td><tr><td><b>Date: </b>'

                echo
    '</td>';
                echo
    '</tr>
                </table>'
    ;
            exit;
        }
        
    }
    ?>

    </body>
    </html>

  5. #5
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please provide the code you are using to better assist you.

  6. #6
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    752
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Quote Originally Posted by ma201dq View Post
    I've not seen you full code, but below is a working sample that you can use or customize to your needs.

    PHP Code:
    <html>
    <head>
    <title></title>
    <style type="text/css">
    <!--
    .row1{
        font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
        font-size:11px;
        font-type:normal;
        padding:2px;
        background-color:#E6E6E6;}
    .row2{
        font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
        font-size:11px;
        font-type:normal;
        padding:2px;
        background-color: #F2F2F2;}
    -->
    </style>
    </head>
    <body>
    <?php

    //check that variables filled
    if(isset($_POST['submit']))
        {

        
    //request type
        
    $test trim($_POST['test']);
        
    $test2 trim($_POST['test2']);
        
    $test3 trim($_POST['test3']);
                    


    $recipient2=$email;
    $toaddress 'email_1@123.com,email_2@123.com';


    $subject 'subject: ';
    $mailcontent 'test: '.$test."\n"
                   
    .'test2: '.$test2."\n"
                   
    .'Wtest3: '.$test3."\n";
                   



    $fromaddress  "From: 123@123.com,\r\n";
    $fromaddress  .="BCC: 123@123.com,1235@123.com\r\n";
    //prototype is mail(string to, string subject, string message, string additional_headers, string additional_parameters)
    mail($toaddress$subject$mailcontent$fromaddress);


    if(!
    mail)
        {
            echo
    '<table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr align="center">
                <td colspan="1" align="left">
                <img src="mpsgi.gif" border="0"></td>
                <tr />
                <td>
                <font size="6">Email Form</font>
                </td>
                <tr />
                <td>&nbsp;</td>
                <tr />
                <td>There was a problem sending your email: </td>
                </table>'
    ;
            exit;
        }
        else
        {
        
        echo
    '<table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr align="center">
                <td colspan="1" align="left">
                <img src="mpsgi.gif" border="0"></td>
                <tr />
                <td>
                <font size="6">Change Control Form</font>
                </td>
                <tr />
                <td>&nbsp;</td>
                <tr />
                <td>Thank you for email.</td><tr><td><b>Date: </b>'

                echo
    '</td>';
                echo
    '</tr>
                </table>'
    ;
            exit;
        }
        
    }
    ?>

    </body>
    </html>


    Now sure how, but your code worked!

    Thanks for showing your magic

  7. #7
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi! maybe i can help you with this just i will send you pm maybe we can discuss it on im.

    WEB-Innovators-Professional and Quality Web Services

    MSN:webinno_sale@web-innovators.com


Bookmarks

Posting Permissions

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