Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/kernel/utility/email.php
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
$this->recipientUserId = $recipient_user_id; | $this->recipientUserId = $recipient_user_id; | ||||
$this->_resetState(); | $this->_resetState(); | ||||
$this->_processSender(); | $this->_processSender(); | ||||
$this->_processRecipients(); | $this->_processRecipients(); | ||||
$this->_changeLanguage(false); | $this->_changeLanguage(false); | ||||
// 1. set headers | |||||
try { | |||||
$message_headers = $this->_getHeaders(); | |||||
} | |||||
catch ( Exception $e ) { | |||||
return $this->setError('Error parsing e-mail message headers'); | |||||
} | |||||
$message_subject = isset($message_headers['Subject']) ? $message_headers['Subject'] : 'Mail message'; | |||||
$this->sender->SetSubject($message_subject); | |||||
foreach ( $message_headers as $header_name => $header_value ) { | |||||
$this->sender->SetEncodedHeader($header_name, $header_value); | |||||
} | |||||
if ( $this->_storeEmailLog() ) { | if ( $this->_storeEmailLog() ) { | ||||
// 1. prepare log | // 1. prepare log | ||||
$this->logData = Array ( | $this->logData = Array ( | ||||
'From' => $this->fromName . ' (' . $this->fromEmail . ')', | 'From' => $this->fromName . ' (' . $this->fromEmail . ')', | ||||
'To' => $this->toName . ' (' . $this->toEmail . ')', | 'To' => $this->toName . ' (' . $this->toEmail . ')', | ||||
'OtherRecipients' => serialize($this->recipients), | 'OtherRecipients' => serialize($this->recipients), | ||||
'Subject' => $message_subject, | |||||
'Status' => EmailLogStatus::SENT, | 'Status' => EmailLogStatus::SENT, | ||||
'ErrorMessage' => '', | 'ErrorMessage' => '', | ||||
'SentOn' => TIMENOW, | 'SentOn' => TIMENOW, | ||||
'TemplateName' => $this->emailTemplate->GetDBField('TemplateName'), | 'TemplateName' => $this->emailTemplate->GetDBField('TemplateName'), | ||||
'EventType' => $this->emailTemplate->GetDBField('Type'), | 'EventType' => $this->emailTemplate->GetDBField('Type'), | ||||
'EventParams' => serialize($this->_getCustomParams()), | 'EventParams' => serialize($this->_getCustomParams()), | ||||
'ToUserId' => $this->recipientUserId, | 'ToUserId' => $this->recipientUserId, | ||||
'ItemPrefix' => $this->getItemPrefix(), | 'ItemPrefix' => $this->getItemPrefix(), | ||||
'ItemId' => isset($this->params['item_id']) ? $this->params['item_id'] : null, | 'ItemId' => isset($this->params['item_id']) ? $this->params['item_id'] : null, | ||||
); | ); | ||||
$this->params['email_access_key'] = $this->_generateAccessKey(); | $this->params['email_access_key'] = $this->_generateAccessKey(); | ||||
} | } | ||||
// 1. set headers | |||||
try { | |||||
$message_headers = $this->_getHeaders(); | |||||
} | |||||
catch ( Exception $e ) { | |||||
return $this->setError('Error parsing e-mail message headers'); | |||||
} | |||||
$message_subject = isset($message_headers['Subject']) ? $message_headers['Subject'] : 'Mail message'; | |||||
$this->sender->SetSubject($message_subject); | |||||
foreach ($message_headers as $header_name => $header_value) { | |||||
$this->sender->SetEncodedHeader($header_name, $header_value); | |||||
} | |||||
if ( $this->_storeEmailLog() ) { | |||||
$this->logData['Subject'] = $message_subject; | |||||
} | |||||
// 3. set body | // 3. set body | ||||
try { | try { | ||||
$html_message_body = $this->_getMessageBody(true); | $html_message_body = $this->_getMessageBody(true); | ||||
$plain_message_body = $this->_getMessageBody(false); | $plain_message_body = $this->_getMessageBody(false); | ||||
} | } | ||||
catch ( Exception $e ) { | catch ( Exception $e ) { | ||||
return $this->setError('Error parsing e-mail message body'); | return $this->setError('Error parsing e-mail message body'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 637 Lines • Show Last 20 Lines |