Thanks Saša.
Yes, the code below sent by Saša is the part that throws exception.
And here is the code I use to send the same mail to another recipient.
                        
                        ....
                        //code above sends the mail to the first recipient. and 
has no problem.

                        //below i want to send the same email to admins
                        if (APPLICATION_ENV == 'production') {
                                $this->_mailer->addTo($to, $toLabel);
                                $this->_mailer->setSubject($subject . 
'[ADMIN]');
                                $this->_mailer->setFrom($from, $fromLabel);
                                $this->_mailer->send();
                        }
the exception thrown is "Subject set twice" from "throw new
Zend_Mail_Exception('Subject set twice');"

Thanks

On Thu, Dec 17, 2009 at 9:00 AM, Саша Стаменковић <[email protected]> wrote:
>  public function setSubject($subject)
>     {
>         if ($this->_subject === null) {
>             $subject = $this->_filterOther($subject);
>             $this->_subject = $this->_encodeHeader($subject);
>             $this->_storeHeader('Subject', $this->_subject);
>         } else {
>             /**
>              * @see Zend_Mail_Exception
>              */
>             require_once 'Zend/Mail/Exception.php';
>             throw new Zend_Mail_Exception('Subject set twice');
>         }
>         return $this;
>     }
> Regards,
> Saša Stamenković
>
>
> On Wed, Dec 16, 2009 at 6:38 AM, scs <[email protected]> wrote:
>>
>> One question from me:
>> I am sending an e-mail to one recipient with a subject and body.
>> Then I want to send the same e-mail/a copy to someone else such as the
>> admin.
>> However, when I try to change the to field or the subject I got errors.
>> Zend_Mail does not allow such things.
>>
>> Yes, adding the next recipient as Bcc is a way but not the preferred one.
>> Is there a way for achieving this kind of job?
>> //set subject
>> //set body
>> //set to
>> send mail
>>
>> //update to
>> //update subject
>> send mail -> gives errors..(something like it does already have a to
>> and subject)
>>
>> thanks
>> scs
>>
>> On Tue, Dec 15, 2009 at 9:17 PM, Alex Howansky <[email protected]>
>> wrote:
>> >
>> >> 1.) Is the best way of sending a single email to every subscriber to
>> >> add
>> >> their address to the BCC list? Are there any foreseeable problems if
>> >> the
>> >> list gets too big?
>> >
>> > I wouldn't recommend this technique unless you have only a handful of
>> > recipients, as many email servers impose a hard cap on the number of
>> > recipients per message. (I believe Gmail has a 100 recipient cap, if I'm
>> > not
>> > mistaken.)
>> >
>> >>    2). Is there some sort of return code for addresses that are
>> >>    non-existent?
>> >
>> > No. Zend_Mail simply hands the message off to your mail server's queue.
>> > What
>> > happens after that (i.e., delivery attempts, failures, etc.) is
>> > encapsulated
>> > within your mail server's internal environment and is not directly
>> > accessible to PHP.
>> >
>> > If your goal is to detect bounces, I'd recommend using the "unique
>> > address
>> > per recipient as a return-path" method. E.g., set your return path to
>> > '[email protected]' where 12345 is some unique identifier for
>> > the
>> > recipient. Then you can monitor the messages that come into the bounce
>> > inbox, decode the address back into your unique id, and set your
>> > software to
>> > disable the appropriate recipient.
>> >
>> > --
>> > Alex Howansky
>> >
>
>

Reply via email to