how to send mail in php with bcc and cc?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prabhunew2005
    New Member
    • Aug 2006
    • 10

    how to send mail in php with bcc and cc?

    hi all,

    I am sending e-mail using php code as follows.

    $sentOk = mail($to,$subje ct,$message,$he aders);

    It is working well. I tested.

    Now i want to send mail to more addresses using 'bcc' and 'cc' options.

    I need to complete this in php code as much as quickly.

    Please help me.

    Advance thanks.

    Regards

    N.Prabhu
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Like this, put them in the $headers variable.

    [php]
    $headers = "From: me@mydomain.com ";
    $headers .= "\r\nCc: he@$hisdomain.c om";
    $headers .= "\r\nBcc: her@$herdomain\ r\n\r\n";
    $headers .= "\r\nX-Mailer: PHP/" . phpversion();
    [/php]
    Ronald :cool:

    Comment

    • prabhunew2005
      New Member
      • Aug 2006
      • 10

      #3
      Originally posted by ronverdonk
      Like this, put them in the $headers variable.

      [php]
      $headers = "From: me@mydomain.com ";
      $headers .= "\r\nCc: he@$hisdomain.c om";
      $headers .= "\r\nBcc: her@$herdomain\ r\n\r\n";
      $headers .= "\r\nX-Mailer: PHP/" . phpversion();
      [/php]
      Ronald :cool:


      Thanks.

      It is working nice. We can send mails with bcc and cc.

      Comment

      • j4uk3n
        New Member
        • Nov 2006
        • 2

        #4
        well i have a problem just by using mail function.
        i downloaded this code from a tutorial website, and save it on

        c:\apache\htdoc s\testsendemail \index.php


        here is the code that i downloaded:

        <?php

        //Check whether the submission is made
        if(isset($hidSu bmit)){

        //Declarate the necessary variables
        $mail_to=$txtEm ailto;
        $mail_from=$txt Emailfrm;
        $mail_sub=$txtS ub;
        $mail_mesg=$txt Msg;

        //Check for success/failure of delivery
        if(mail($mail_t o,$mail_sub,$ma il_mesg,"From:$ mail_from/r/nReply-to:$mail_from") )
        echo "<span class='textred' >E-mail has been sent successfully from $mail_sub to $mail_to</span>";
        else
        echo "<span class='textred' >Failed to send the E-mail from $mail_sub to $mail_to</span>";
        }
        ?>

        ||||
        ||||
        ||||
        ||||
        ||||

        this is the warning message that i received:

        Warning: Failed to Connect in c:\apache\htdoc s\testsendemail \index.php on line 13
        Failed to send the E-mail from to


        what should i do?
        sorry i'm a total newbie here, just started to learn how to use php.

        tQ in advance

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Have you defined the correct email settings in your PHP.INI? If you dont't know, show them.

          Ronald :cool:

          Comment

          Working...