PHPMailer Question about using CC in Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cover

    PHPMailer Question about using CC in Forms

    My form processes the lines below just fine so long as there's
    something in the cc field (which I'm trying to leave optional). If the
    cc field of the form is left blank, I get an error. I need an if
    statement where the cc is optionally blank and the $to still works. As
    I have it, the $to line below works well because there's always going
    to be an entry however again, the cc won't be used 100% of the time.
    I was toying around with the if statement below but don't have it
    figured out yet. Any help is appreciated. TIA

    $mail->AddAddress($ar rEmailAddress[$to]);
    $mail->AddCC($arrEmai lAddress[$cc]);


    ----------code below clearly not there yet for the cc field-----------
    if ($cc=''''){
    $mail->AddCC($cc);
    }

  • bill

    #2
    Re: PHPMailer Question about using CC in Forms

    cover wrote:
    My form processes the lines below just fine so long as there's
    something in the cc field (which I'm trying to leave optional). If the
    cc field of the form is left blank, I get an error. I need an if
    statement where the cc is optionally blank and the $to still works. As
    I have it, the $to line below works well because there's always going
    to be an entry however again, the cc won't be used 100% of the time.
    I was toying around with the if statement below but don't have it
    figured out yet. Any help is appreciated. TIA
    >
    $mail->AddAddress($ar rEmailAddress[$to]);
    $mail->AddCC($arrEmai lAddress[$cc]);
    >
    >
    ----------code below clearly not there yet for the cc field-----------
    if ($cc=''''){
    $mail->AddCC($cc);
    }
    >
    I believe you would want

    if ($cc != "") $mail->AddCC($cc);

    Comment

    • shimmyshack

      #3
      Re: PHPMailer Question about using CC in Forms

      On Jun 2, 3:58 pm, cover <coverlandNOSPA M...@yahoo.comw rote:
      My form processes the lines below just fine so long as there's
      something in the cc field (which I'm trying to leave optional). If the
      cc field of the form is left blank, I get an error. I need an if
      statement where the cc is optionally blank and the $to still works. As
      I have it, the $to line below works well because there's always going
      to be an entry however again, the cc won't be used 100% of the time.
      I was toying around with the if statement below but don't have it
      figured out yet. Any help is appreciated. TIA
      >
      $mail->AddAddress($ar rEmailAddress[$to]);
      $mail->AddCC($arrEmai lAddress[$cc]);
      >
      ----------code below clearly not there yet for the cc field-----------
      if ($cc=''''){
      $mail->AddCC($cc);
      }
      do you mean?

      if( $cc != '' )
      {
      $mail->AddCC($cc);
      }

      you could google for "conditiona ls in php" for more help on using if
      statements, but my advice is - if you are this new to php coding, DONT
      play with scripts, you could easily create a working spam bot, which
      would quickly increase your headaches by many orders of magnitude.

      Comment

      • Tom

        #4
        Re: PHPMailer Question about using CC in Forms


        "shimmyshac k" <matt.farey@gma il.comwrote in message
        news:1181034443 .892877.186310@ q66g2000hsg.goo glegroups.com.. .
        On Jun 2, 3:58 pm, cover <coverlandNOSPA M...@yahoo.comw rote:
        My form processes the lines below just fine so long as there's
        something in the cc field (which I'm trying to leave optional). If the
        cc field of the form is left blank, I get an error. I need an if
        statement where the cc is optionally blank and the $to still works. As
        I have it, the $to line below works well because there's always going
        to be an entry however again, the cc won't be used 100% of the time.
        I was toying around with the if statement below but don't have it
        figured out yet. Any help is appreciated. TIA

        $mail->AddAddress($ar rEmailAddress[$to]);
        $mail->AddCC($arrEmai lAddress[$cc]);

        ----------code below clearly not there yet for the cc field-----------
        if ($cc=''''){
        $mail->AddCC($cc);
        }
        >
        do you mean?
        >
        if( $cc != '' )
        {
        $mail->AddCC($cc);
        }
        >
        you could google for "conditiona ls in php" for more help on using if
        statements, but my advice is - if you are this new to php coding, DONT
        play with scripts, you could easily create a working spam bot, which
        would quickly increase your headaches by many orders of magnitude.
        >
        If you are using input from a web form to send email, you need to be really
        careful that spammers don't hijack your script.

        As an example that can submit an email address for the "To" header then add
        a whole bunch of other addresses in the CC or Bcc header.

        You need to be really careful about checking for conditions like that, such
        testing for new line characters, in the form information people are
        submitting to you.

        Tom
        --

        Newsguy.com
        90+ Days Retention
        99% Article Completion
        Create Your Own NZB Files




        Comment

        Working...