PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
SMTP Mail not reach to Bcc and Cc

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
keskin



Joined: 27 Aug 2007
Posts: 2

PostPosted: Fri Feb 15, 2008 10:23 pm    Post subject: SMTP Mail not reach to Bcc and Cc Reply with quote

im getting a problem with sending email using the pear Mail class.
my mail is reach to To but not reach Bcc and CC

sorry my poor english please help!

here is my code

Code:

<?php
error_reporting(6143);

function mail_gonder($from, $tobcc, $body, $subject)
{
   require_once "Mail.php";
   require_once "Mail/mime.php";

   $headers = array ("From"       => $from,
                 "Subject"    => $subject);

   if(is_array($tobcc))
      $headers = array_merge($tobcc, $headers);
   else
      $headers['To'] = $tobcc;

   $mime = new Mail_mime("\n");
   $mime->setHTMLBody($body);
   $body = $mime->get(array("html_charset" => "utf-8"));
   $headers = $mime->headers($headers);

   $host = "mail.mydomain.com";
   $username = "test1";
   $password = "1234";
   
   $smtp = Mail::factory('smtp',
     array ('host' => $host,
      'auth' => true,
      'username' => $username,
      'password' => $password,
      'debug'=>true));
   
   $mail = $smtp->send($headers['To'], $headers, $body);
   
   var_dump($smtp);
   var_dump($headers);
   var_dump($mail);
   
   if (PEAR::isError($mail))
      return false;
   else
      return true;
}

$from = "test1@mydomain.com";
$tobcc   = array('To' => "Test2 <test2@mydomain.com>", "Cc" => "Test3 <test3@mydomain.com>", "Bcc" => "Test4 <test4@mydomain.com>");
$subject = 'test - '.date("d/m/Y H:i:s");
$body = "<html><head><title>title</title></head><body><p>message</p></body></html>";
echo "<pre>";
mail_gonder($from, $tobcc, $body, $subject);
echo "</pre>";
?>
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Fri Feb 15, 2008 11:33 pm    Post subject: Reply with quote

The headers array is only for "display" purposes. You'll have to pass all addresses to the first parameter of the send() method, otherwise only one email will be sent.
Back to top
View user's profile Send private message
keskin



Joined: 27 Aug 2007
Posts: 2

PostPosted: Sat Feb 16, 2008 12:13 pm    Post subject: Reply with quote

thanks mark
That worked great
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software