 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
keskin
Joined: 27 Aug 2007 Posts: 2
|
Posted: Fri Feb 15, 2008 10:23 pm Post subject: SMTP Mail not reach to Bcc and Cc |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1048
|
Posted: Fri Feb 15, 2008 11:33 pm Post subject: |
|
|
| 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 |
|
 |
keskin
Joined: 27 Aug 2007 Posts: 2
|
Posted: Sat Feb 16, 2008 12:13 pm Post subject: |
|
|
thanks mark
That worked great |
|
| Back to top |
|
 |
|
|
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
|
|