PHP Classes

Problem with sending a CC command

Recommend this page to a friend!

      SMTP E-mail sending class  >  All threads  >  Problem with sending a CC command  >  (Un) Subscribe thread alerts  
Subject:Problem with sending a CC command
Summary:Problem with sending a CC(BCC) command
Messages:5
Author:alexander
Date:2008-12-13 16:14:52
Update:2010-09-15 09:20:19
 

  1. Problem with sending a CC command   Reply   Report abuse  
Picture of alexander alexander - 2008-12-13 16:14:54
This is my code:
$smtp->SendMessage($from_mail,array("mail.to@gmail.com"),array("Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"), "From: $from", "X-Mailer: The Bat! (v4.0.24.11) Professional", "Reply-To: $from", "X-Priority: 3 (Normal)", "To: mail.to@gmail.com", "CC: mail.copy@gmail.com", "Subject: $subject", "MIME-Version: 1.0", "Content-Type: text/plain; charset=windows-1251", "Content-Transfer-Encoding: quoted-printable"),
$text);

Message reached to the address mail.to@gmail.com, and did not reach to mail.copy@gmail.com.. I'm try many times...

what is a problem in?

Sorry for my bad English :)

  2. Re: Problem with sending a CC command   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-12-13 20:49:25 - In reply to message 1 from alexander
Adding Cc: or Bcc: headers to the message does not add the respective addresses to the recipients list itself.

You need to pick the recipient addresses from those headers and add them to the recipients parameter.

Anyway, this SMTP class is not supposed to be used directly. Use it in conjunction with the MIME message class, so it extracts the recipients from the headers besides other measures to generate messages that are compliant with the Internet e-mail standards.

phpclasses.org/mimemessage

  3. Re: Problem with sending a CC command   Reply   Report abuse  
Picture of Mihaita Nita Mihaita Nita - 2010-09-15 09:20:19 - In reply to message 1 from alexander
the problem is in the design of the class. here is a hack:

in smtp.php

Function SendMessage($sender,$recipients,$headers,$body)
{
if(($success=$this->Connect()))
{
if(($success=$this->MailFrom($sender)))
{
for($recipient=0;$recipient<count($recipients);$recipient++)
{
if(!($success=$this->SetRecipient($recipients[$recipient])))
break;
}

becames

Function SendMessage($sender,$recipients,$headers,$body)
{
if(($success=$this->Connect()))
{
if(($success=$this->MailFrom($sender)))
{
for($recipient=0;$recipient<count($recipients);$recipient++)
{
$a = explode(',',$recipients[$recipient]);
while (list(, $temp) = each($a))
{
if(!($success=$this->SetRecipient($temp)))
break;
}
}

is not healthy, but it works. only for "," spliter in $to parameter.

  4. Re: Problem with sending a CC command   Reply   Report abuse  
Picture of Yadhu Krishnan Yadhu Krishnan - 2015-12-27 10:12:41 - In reply to message 3 from Mihaita Nita
How can i add a BCC to this function ?

$smtp->SendMessage('test@gmail.com',$to,$strHeader,"");

This is how i calling function.

where $to is array of email id's but i want to add BCC here.

how can i done that?

  5. Re: Problem with sending a CC command   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-12-27 19:43:16 - In reply to message 4 from Yadhu Krishnan
You need to pass an array with all recipient addresses including those in Cc: because the class will not process the message headers to figure all addresses that will receive the message.