1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19:
20: 21: 22: 23: 24:
25: class MailTransport extends AbstractTransport {
26:
27: 28: 29: 30: 31: 32: 33:
34: public function send(CakeEmail $email) {
35: $eol = PHP_EOL;
36: if (isset($this->_config['eol'])) {
37: $eol = $this->_config['eol'];
38: }
39: $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc'));
40: $to = $headers['To'];
41: unset($headers['To']);
42: $headers = $this->_headersToString($headers, $eol);
43: $message = implode($eol, $email->message());
44: if (ini_get('safe_mode') || !isset($this->_config['additionalParameters'])) {
45: if (!@mail($to, $email->subject(), $message, $headers)) {
46: throw new SocketException(__d('cake_dev', 'Could not send email.'));
47: }
48: } elseif (!@mail($to, $email->subject(), $message, $headers, $this->_config['additionalParameters'])) {
49: throw new SocketException(__d('cake_dev', 'Could not send email.'));
50: }
51: return array('headers' => $headers, 'message' => $message);
52: }
53:
54: }
55: