Path

ez components / documentation / api reference / 2007.2 / mail


Mail

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Source for file mta_transport.php

Documentation is available at mta_transport.php

 1. <?php
 2. /**
 3.  * File containing the ezcMailMtaTransport class
 4.  *
 5.  * @package Mail
 6.  * @version 1.4
 7.  * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
 8.  * @license http://ez.no/licenses/new_bsd New BSD License
 9.  */
10.  
11. /**
12.  * Implementation of the mail transport interface using the system MTA.
13.  *
14.  * The system MTA translates to sendmail on most Linux distributions.
15.  *
16.  * Qmail insists it should only have "\n" linebreaks and will send
17.  * garbled messages with the default "\r\n" setting.
18.  * Use ezcMailTools::setLineBreak( "\n" ) before sending mail to fix this issue.
19.  *
20.  * @package Mail
21.  * @version 1.4
22.  * @mainclass
23.  */
24. class ezcMailMtaTransport implements ezcMailTransport
25. {
26.     /**
27.      * Constructs a new ezcMailMtaTransport.
28.      */
29.     public function __construct(  )
30.     {
31.     }
32.  
33.     /**
34.      * Sends the mail $mail using the PHP mail method.
35.      *
36.      * Note that a message may not arrive at the destination even though
37.      * it was accepted for delivery.
38.      *
39.      * @throws ezcMailTransportException
40.      *          if the mail was not accepted for delivery by the MTA.
41.      * @param ezcMail $mail 
42.      */
43.     public function sendezcMail $mail )
44.     {
45.         $mail->appendExcludeHeadersarray'to''subject' ) );
46.         $headers rtrim$mail->generateHeaders() )// rtrim removes the linebreak at the end, mail doesn't want it.
47.  
48.         if ( ( count$mail->to count$mail->cc count$mail->bcc ) ) )
49.         {
50.             throw new ezcMailTransportException'No recipient addresses found in message header.' );
51.         }
52.         $additionalParameters "";
53.         if isset$mail->returnPath ) )
54.         {
55.             $additionalParameters "-f{$mail->returnPath->email}";
56.         }
57.         $success mailezcMailTools::composeEmailAddresses$mail->to ),
58.                          $mail->getHeader'Subject' )$mail->generateBody()$headers$additionalParameters );
59.         if $success === false )
60.         {
61.             throw new ezcMailTransportException'The email could not be sent by sendmail' );
62.         }
63.     }
64. }
65. ?>
Last updated: Mon, 17 Dec 2007