Re: Cc-Problems with PEAR_Mail
| From: | Jacques Marneweck | Date: | Thu, 05 Apr 2007 10:33:42 +0000 |
| Subject: | Re: Cc-Problems with PEAR_Mail | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27008@lists.php.net to get a copy of this message | ||
You are only sending to the recipients you have specified by the $to.
You want to add the cc users to an array with the to users and pass
that array to:
$mail->send($recips, $hdrs, $body);
Regards
--jm
On 4/4/07, Stephan Wentz <stephan@wentz.it> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all.
I'm experiencing some problems with PEAR_Mail and PEAR_Mail_mime, maybe
someone can clear these up for me...
My app uses PEAR_Mail for sending mails, it can be configured to use the
smtp- and the mail-driver. The generated mail has one To-recipient and
several other Cc-recipients.
Cc-recipients are added through Mail_mime's addCC()-method, the
To-recipient is of course set through Mail's send()-method.
<example>
require_once 'Mail.php';
require_once 'Mail/mime.php';
$driver = 'mail';
$params = array();
$to = 'test1@example.org';
$mime = new Mail_mime();
$mime->addCc('test2@example.org');
$mime->addCc('test3@example.org');
$mime->addCc('test4@example.org');
$mime->setSubject('testsubject');
$mime->setTXTBody('testbody');
$headers = array(
'To' => 'test <'.$to.'>',
'From' => 'test@example.org'
);
$body = $mime->get();
$hdrs = $mime->headers($headers);
$mail =& Mail::factory($driver, $params);
$mail->send($to, $hdrs, $body);
</example>
This one works fine, no problems at all.
Now when executing the same script with...
<snip>
$driver = 'smtp';
$params = array('host'=>'localhost');
</snip>
... ONLY the $to-recipients receives a mail, the Cc-recipients are skipped.
I logged at the mta's (postfix) log-file, and it really only sends one
email when sending through the smtp-driver. Everything ok there with the
mail-driver.
I thought that one could transparently switch the driver, without
modifying the code, is this wrong?
It seems like I have to put every recipient in the $to-part when sending
through smtp, why? Does the php-mail()-function do some magic stuff there?
I tried adding all recipients merged to the To-recipients, which works
with smtp, but it doesn't for the mail-driver, I have all recipients in
the To-recipients there, and additional the Cc-recipients...
Is there a common solve for this problem?
Bye, Stephan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGE5y28qQ9XV7tBNQRAhFAAKCdwm0eWMLk+GbIkyn4HugvEssRUwCg7hSH
3aWVo+ZHEy7HlR1rXcicgQo=
=Oq1p
-----END PGP SIGNATURE-----
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Jacques Marneweck
http://www.powertrip.co.za/
http://www.powertrip.co.za/blog/
http://www.ataris.co.za/