Tokyoj

Topic: How to add CC or BCC to Apply Online?

In my Apply Online page I've added a 'Send copy to:' field with the ID  $my_email so the applicant can CC themselves on the Application or BCC so companies don't see that applicants have CC'd themselves in the email...kind of weird IMO.

I thought it would be smoother then developing a whole new section just so applicants can track what they applied to. This way applicants can have a record themselves. I'm not sure of the syntax for adding CC or BCC. Here's what my class.Postman.php has now...(I'm assuming that's the correct file).

How can I get it to include the $my_email string when the application is send?
I thought it was as simple as adding one of the below under the FromName string...
$mail-> CC = $data['my_email'];
...or...
$mail-> BCC = $data['my_email'];

...but that didn't work.

// Send online application to employer
     public function MailApplyOnline($data)
    {
        $extra = '\n\n---\nThis email is sent from' . $_SERVER['HTTP_REFERER'] . 'via JobGaint.';
        $mail = new PHPMailer();
        $mail->From = $data['apply_email'];
        $mail->FromName = $data['apply_name'];                   
    $mail->Body = str_replace(array('\r\n', '\r', '\n'), '<br />', $data['apply_msg'] . $extra);
    $mail->AltBody = $data['apply_msg'] . $extra;
        $mail->Subject = "[" . SITE_NAME . "]'" . $data['job_title'] . "'application";
    $mail->AddAddress($data['company_email'], $data['company_name']);
    }

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

Chronos

Re: How to add CC or BCC to Apply Online?

You're pretty close to getting it working really, PHPMailer uses AddBCC instead of just BCC (unlike From, FromName etc.). It should work by using the following code, I didn't test though.

Code:
$mail->AddBCC = $data['my_email'];
Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

Tokyoj

Re: How to add CC or BCC to Apply Online?

Thanks Chronos.
I was hoping it would be that easy but still no CC coming in....hmmm...also tried with
$mail->AddCC = $data['apply_email'];
but that didn't work either.

I'm only editing class.Postman.php and not class.phpmailer.php
Looking through class.phpmailer.php I found this but it's beyond my skills.

    /**
     * Adds a "Cc" address. Note: this function works
     * with the SMTP mailer on win32, not with the "mail"
     * mailer. 
     * @param string $address
     * @param string $name
     * @return void
    */
    function AddCC($address, $name = "") {
        $cur = count($this->cc);
        $this->cc[$cur][0] = trim($address);
        $this->cc[$cur][1] = $name;
    }

    /**
     * Adds a "Bcc" address. Note: this function works
     * with the SMTP mailer on win32, not with the "mail"
     * mailer. 
     * @param string $address
     * @param string $name
     * @return void
     */
    function AddBCC($address, $name = "") {
        $cur = count($this->bcc);
        $this->bcc[$cur][0] = trim($address);
        $this->bcc[$cur][1] = $name;
    }

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

Chronos

Re: How to add CC or BCC to Apply Online?

Are you sure the class is receiving the variable? Try placing an "echo $data['apply_email'];" before and see if it works. The code of PHPMailer seems fine, it just shows there's also the option to add a name to the adres (but not needed).

Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

putypuruty

Re: How to add CC or BCC to Apply Online?

Hi, guys!

This is the correct way to do it:

Code:
$mail->AddBCC($data['my_email']);

Tokyoj

Re: How to add CC or BCC to Apply Online?

Chronos, Putypuruty. Thank you.
Gotta love tag teams...

$mail->AddBCC($data['my_email']);

works smoothly. I'll post the process in Tutorials.

Friday+slow day at work+sunshine=a beer

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)