Hi Mundy,

Thanks for your quick response. When I put 'proper smtp status code' I mean
I expect to get the smtp status code in digits. Our mail server has set up a
set of custom SMTP status codes. So, when I have to deal with this mail
server, I need to retrieve the smtp status code to determine which kind of
message should be delivered to our customer to describe the proper status of
the email sending activities. Therefore, our customers don't need to look up
our FAQs to see what actually happens and why it happens.

Here is my code

                require_once 'Zend/Mail.php';
        require_once 'Zend/Mail/Transport/Smtp.php';

        $transporter     = new Zend_Mail_Transport_Smtp('mail.domain.com',
$config);
        Zend_Mail::setDefaultTransport($transporter);

        $this->_mailer   = new Zend_Mail();

        $this->_mailer->addHeader('X-MailGenerator', 'CustomerService');
        $this->_mailer->setReturnPath('[EMAIL PROTECTED]');
        $this->_mailer->setFrom('[EMAIL PROTECTED]', 'Automatic Mail
Sender');
        $this->_mailer->addTo($email, $fullName);

        // Email subject title
        $this->_mailer->setSubject('Account activation');
        $this->_mailer->setBodyText($message);

        try
        {
            $this->_mailer->send();
            return true;
        }
        catch (Exception $ex)
        {
            $this->_errorMessage = $ex->getMessage(); // Error message like
that: 531 Message_here_
            return false;
        }

It is easy to parse the Exception message to get the smtp status code but I
am not sure that if Zend_Mail has a specific API to do that task.

Thanks,

Dinh

On 8/2/07, Simon Mundy <[EMAIL PROTECTED]> wrote:
>
> Hi Dinh
> Can you explain what you mean by a 'proper' smtp status code? Do you mean
> the code returned by the server at the end of the transaction? Or do you
> need a transcript of the all requests/responses?
>
> The Zend_Mail_Transport_Smtp transport object lets you retrieve a
> connection instance. The connection instance can then give you a complete
> transcript of the conversation between client and server.
>
> E.g.
>
> $tr = new Zend_Mail_Transport_Smtp();
> Zend_Mail::setDefaultTransport($tr);
>
> $mail = new Zend_Mail();
> ... etc ...
> $mail->send();
>
> $log = $tr->getConnection()->getLog();
>
> If you are performing multiple mail send() operations you can also reset
> the log between each new mail:-
>
> $tr->getConnection()->resetLog();
>
> Hope this answers your question.
>
> Cheerio
>
> Hi all,
>
> I can not find any API in Zend_Mail that allows to retrieve proper smtp
> status code. Am I missing something or I need to do it myself?
>
> Thanks,
>
> Dinh
>
>
>
> --
>
> Simon Mundy | Director | PEPTOLAB
>
> """ " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
> 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
> Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
> http://www.peptolab.com
>
>


-- 
Nobody in nowhere

Reply via email to