Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2009
    Posts
    28

    Post PhpMailer Difficulty

    A while back when eUKHost changed php mail() function I had to re-work some code quickly.

    Now i'm very novice with coding, but following one of the forum links I managed to re-do things with phpMailer. (I believe). However, I can't get the BCC part to work.

    Does the AddCC and AddBCC function not work on our servers? Or is it something I'm doing wrong.

    From Worx International Inc. I find:

    AddCC($address, $name = "")
    Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

    AddBCC($address, $name = "")
    Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

    Is there a way to do BCC's?

    Thank you,
    ~devs

  2. #2

    Default

    Hello Devs,

    I have not tried this code but this may help you with your coding :


    <?php
    $subject = "Your Test Email";

    $message = " $todayis [EST] \n
    Inquiry by: $visitor \n
    Their email: $visitormail \n
    Phone: $myphone \n
    Sender IP address: $MyIP \n
    Message: $notes \n
    ";

    $message = $message."This is a test message. \n";

    include("Mail.php");
    /* mail setup recipients, subject etc */

    $To=(string)$SendToEmail ;
    $bcc = "WEBMASTERS_EMAIL_ADDRESS";
    $recipients = $To.",".$bcc;
    $headers["From"] = "youremailaddress";
    $headers["To"] = $To;
    $headers["Reply-To"] = $visitormail;
    $headers["Subject"] = $subject;
    $mailmsg = $message;
    /* SMTP server name, port, user/passwd */
    $smtpinfo["host"] = "smtpservername";
    $smtpinfo["port"] = "25";
    $smtpinfo["auth"] = true;
    $smtpinfo["username"] = "Emailaddress";
    $smtpinfo["password"] = "emailpassword";
    /* Create the mail object using the Mail::factory method */
    $mail_object =& Mail::factory("smtp", $smtpinfo);
    /* Ok send mail */
    $mail_object->send($recipients, $headers, $mailmsg);

    ?>
    Regards,
    Silvester J

  3. #3
    Join Date
    Jan 2009
    Posts
    28

    Default

    Hello, thank-you for the reply.

    The type of coding I'm using is as below. I believe it uses a sort of PHPMailer 'plugin'/'software'.

    ob_start();
    require("class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->IsSMTP(); // set mailer to use SMTP
    $mail->Host = "XXXX"; // specify main and backup server
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "XXXX"; // SMTP username
    $mail->Password = "XXXX"; // SMTP password

    $mail->From = "admin@eye2eyerecruitment.com";
    $mail->FromName = "Eye2eye Recruitment";
    $mail->AddAddress("admin@eye2eyerecruitment.com");

    $mail->WordWrap = 50; // set word wrap to 50 characters
    $mail->IsHTML(true); // set email format to HTML
    $mail->Subject = "Eye2eye --- Locum Registered";

    $mail->Body = "Hello this is a message";

    $mail->AltBody = "This is the body in plain text for non-HTML mail clients.";

    if(!$mail->Send())
    {
    echo "Message could not be sent. <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
    }
    Not sure how to successfully use it to do BCC's or CC's.

    ~devs

  4. #4

    Default

    Hello ,

    Try to add AddBCC as below

    $mail->AddBCC("bcc@yourdomain.com");

    Example :


    ob_start();
    require("class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->IsSMTP(); // set mailer to use SMTP
    $mail->Host = "XXXX"; // specify main and backup server
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "XXXX"; // SMTP username
    $mail->Password = "XXXX"; // SMTP password

    $mail->From = "admin@eye2eyerecruitment.com";
    $mail->FromName = "Eye2eye Recruitment";
    $mail->AddAddress("admin@eye2eyerecruitment.com");
    $mail->AddBCC("bcc@yourdomain.com"); // replace it with your existing email id

    $mail->WordWrap = 50; // set word wrap to 50 characters
    $mail->IsHTML(true); // set email format to HTML
    $mail->Subject = "Eye2eye --- Locum Registered";

    $mail->Body = "Hello this is a message";

    $mail->AltBody = "This is the body in plain text for non-HTML mail clients.";

    if(!$mail->Send())
    {
    echo "Message could not be sent. <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
    }
    Thanks,
    Silvester J

  5. #5
    Join Date
    Jan 2009
    Posts
    28

    Unhappy Still no luck

    Hello Silvester,

    Been a while but still having this same problem and it's becoming more important to fix it.

    I've tried
    $mail->AddBCC("bcc@yourdomain.com"); etc and it didn't help.

    I tried running the whole script twice
    for($foo=1; $foo<=2; $foo++)
    {
    if ($foo=="1")
    {$email="someone@home.com";}
    if ($foo=="2")
    {$email="someone@home.com";}

    MAILER FUNCTION
    $mail->AddAddress($email, "Name");
    }

    ...and that hasn't worked either.

    In the class.mailer.php file I read the following. I don't know if it's relevant or explains why it's not working for me. And even if it does, i need a way around it.

    /**
    * 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;
    }



    Please help.
    ~devsie

  6. #6

    Default PhpMailer Difficulty

    Hi Devsie,

    Please give a try to below code .

    $mail->AddBCC($data['my_email']);
    Note :: Replace "my_email" to the actual email address.

  7. #7
    Join Date
    Jan 2009
    Posts
    28

    Default

    Thank you for your suggestion. Unfortunately, that didn't work.

    I used :
    PHP Code:
    $mail->AddBCC($data['admin@eye2eyerecruitment.com']); 
    And got back:

    HTML Code:
    "Message could not be sent.
    
    Mailer Error: Language string failed to load: recipients_failed" error.
    If I take out the php line you suggested, it works again, but obviously only sends to one recipient. Any further suggestions?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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