| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of SwiftMailer. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * (c) 2004-2009 Chris Corbyn | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Sends Messages using the mail() function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * It is advised that users do not use this transport if at all possible | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * since a number of plugin features cannot be used in conjunction with this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * transport due to the internal interface in PHP itself. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * The level of error reporting with this transport is incredibly weak, again | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * due to limitations of PHP's internal mail() function.  You'll get an | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * all-or-nothing result from sending. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @author Chris Corbyn | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | class Swift_Transport_MailTransport implements Swift_Transport | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** Additional parameters to pass to mail() */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $_extraParams = '-f%s'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** The event dispatcher from the plugin API */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     private $_eventDispatcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * Create a new MailTransport with the $log. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @param Swift_Events_EventDispatcher $eventDispatcher | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 16 |  |     public function __construct(Swift_Events_EventDispatcher $eventDispatcher) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 16 |  |         $this->_eventDispatcher = $eventDispatcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 16 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * Not used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     public function isStarted() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * Not used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function start() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * Not used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     public function stop() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * Set the additional parameters used on the mail() function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * This string is formatted for sprintf() where %s is the sender address. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @param string $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * @return Swift_Transport_MailTransport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 2 |  |     public function setExtraParams($params) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 2 |  |         $this->_extraParams = $params; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 2 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * Get the additional parameters used on the mail() function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * This string is formatted for sprintf() where %s is the sender address. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     public function getExtraParams() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         return $this->_extraParams; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * Send the given Message. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * Recipient/sender data will be retrieved from the Message API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * The return value is the number of recipients who were accepted for delivery. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @param Swift_Mime_Message $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * @param string[]           $failedRecipients An array of failures by-reference | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @throws Swift_TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 15 |  |     public function send(Swift_Mime_Message $message, &$failedRecipients = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 15 |  |         $failedRecipients = (array)$failedRecipients; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 | 15 |  |         $evt = $this->_eventDispatcher->createSendEvent($this, $message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 15 |  |         if ($evt) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             if ($evt->bubbleCancelled()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                 return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $count = ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 15 |  |             count((array)$message->getTo()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 15 |  |             + count((array)$message->getCc()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 15 |  |             + count((array)$message->getBcc()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         /* | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         // TODO: check if we need this check, breaks "Mockery"-Tests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         if ($count == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 15 |  |         $toHeader = $message->getHeaders()->get('To'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 15 |  |         $subjectHeader = $message->getHeaders()->get('Subject'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 15 |  |         if (!$toHeader) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             $this->_throwException(new Swift_TransportException('Cannot send message without a recipient')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 15 |  |         $to = $toHeader->getFieldBody(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 15 |  |         $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 15 |  |         $reversePath = $this->_getReversePath($message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         // Remove headers that would otherwise be duplicated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 15 |  |         $message->getHeaders()->remove('To'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 15 |  |         $message->getHeaders()->remove('Subject'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 15 |  |         $messageStr = $message->toString(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 | 15 |  |         $message->getHeaders()->set($toHeader); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 15 |  |         $message->getHeaders()->set($subjectHeader); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         // Separate headers from body | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 15 |  |         if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 | 3 |  |             $headers = substr($messageStr, 0, $endHeaders) . "\r\n"; // Keep last EOL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 3 |  |             $body = substr($messageStr, $endHeaders + 4); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 12 |  |             $headers = $messageStr . "\r\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 | 12 |  |             $body = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 | 15 |  |         unset($messageStr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 15 |  |         if ("\r\n" != PHP_EOL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             // Non-windows (not using SMTP) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 15 |  |             $headers = str_replace("\r\n", PHP_EOL, $headers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 15 |  |             $subject = str_replace("\r\n", PHP_EOL, $subject); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 15 |  |             $body = str_replace("\r\n", PHP_EOL, $body); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             // Windows, using SMTP | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             $headers = str_replace("\r\n.", "\r\n..", $headers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             $subject = str_replace("\r\n.", "\r\n..", $subject); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             $body = str_replace("\r\n.", "\r\n..", $body); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 15 |  |         if ($this->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 1 |  |             if ($evt) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                 $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                 $evt->setFailedRecipients($failedRecipients); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 1 |  |                 $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 14 |  |             $failedRecipients = array_merge( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                 $failedRecipients, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 14 |  |                 array_keys((array)$message->getTo()), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 14 |  |                 array_keys((array)$message->getCc()), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 14 |  |                 array_keys((array)$message->getBcc()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 14 |  |             if ($evt) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |                 $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |                 $evt->setFailedRecipients($failedRecipients); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |                 $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             // TODO: Why do we do this only on error? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             // -> take a look at "AbstractSmtpTransport" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 14 |  |             $message->generateId(); // Make sure a new Message ID is used | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 | 14 |  |             $count = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 15 |  |         return $count; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      * Register a plugin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @param Swift_Events_EventListener $plugin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     public function registerPlugin(Swift_Events_EventListener $plugin) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         $this->_eventDispatcher->bindEventListener($plugin); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * Throw a TransportException, first sending it to any listeners | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * @param Swift_TransportException $e | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      * @throws Swift_TransportException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 223 |  | View Code Duplication |     protected function _throwException(Swift_TransportException $e) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         $evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         if ($evt) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             if (!$evt->bubbleCancelled()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                 throw $e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             throw $e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * Send mail via the mail() function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |      * This method takes the same arguments as PHP mail(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |      * @param string $to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |      * @param string $subject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      * @param string $body | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |      * @param string $headers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      * @param string $extraParams | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 250 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  |     public function mail($to, $subject, $body, $headers = null, $extraParams = null) | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  |         if (!ini_get('safe_mode')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  |             return @mail($to, $subject, $body, $headers, $extraParams); | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  |         return @mail($to, $subject, $body, $headers); | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      * Determine the best-use reverse path for this message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |      * @param Swift_Mime_Message $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |      * @return mixed|null|string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 267 | 15 | View Code Duplication |     private function _getReversePath(Swift_Mime_Message $message) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 | 15 |  |         $return = $message->getReturnPath(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 | 15 |  |         $sender = $message->getSender(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 | 15 |  |         $from = $message->getFrom(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 | 15 |  |         $path = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 | 15 |  |         if (!empty($return)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 | 3 |  |             $path = $return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 | 12 |  |         } elseif (!empty($sender)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             $keys = array_keys($sender); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             $path = array_shift($keys); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 | 12 |  |         } elseif (!empty($from)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             $keys = array_keys($from); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |             $path = array_shift($keys); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 | 15 |  |         return $path; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      * Return php mail extra params to use for invoker->mail. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |      * @param $extraParams | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |      * @param $reversePath | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |      * @return mixed <string|null> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 | 15 |  |     private function _formatExtraParams($extraParams, $reversePath) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 | 15 |  |         if (strpos($extraParams, '-f%s') !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 | 14 |  |             $extraParams = empty($reversePath) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 | 12 |  |                 ? str_replace('-f%s', '', $extraParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 | 14 |  |                 : sprintf($extraParams, escapeshellarg($reversePath)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 | 15 |  |         return !empty($extraParams) ? $extraParams : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 304 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 305 |  |  |  | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.