public function MailEntity::getHeaders in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::getHeaders()
- 3.x src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::getHeaders()
Returns the mail headers.
Parameters
$headers: The default mail headers.
Return value
Mail headers as an array.
Overrides MailInterface::getHeaders
File
- src/
Mail/ MailEntity.php, line 117
Class
- MailEntity
- Default mail class for entities.
Namespace
Drupal\simplenews\MailCode
public function getHeaders(array $headers) {
// If receipt is requested, add headers.
if ($this->newsletter->receipt) {
$headers['Disposition-Notification-To'] = $this
->getFromAddress();
$headers['X-Confirm-Reading-To'] = $this
->getFromAddress();
}
// Add priority if set.
switch ($this->newsletter->priority) {
case SIMPLENEWS_PRIORITY_HIGHEST:
$headers['Priority'] = 'High';
$headers['X-Priority'] = '1';
$headers['X-MSMail-Priority'] = 'Highest';
break;
case SIMPLENEWS_PRIORITY_HIGH:
$headers['Priority'] = 'urgent';
$headers['X-Priority'] = '2';
$headers['X-MSMail-Priority'] = 'High';
break;
case SIMPLENEWS_PRIORITY_NORMAL:
$headers['Priority'] = 'normal';
$headers['X-Priority'] = '3';
$headers['X-MSMail-Priority'] = 'Normal';
break;
case SIMPLENEWS_PRIORITY_LOW:
$headers['Priority'] = 'non-urgent';
$headers['X-Priority'] = '4';
$headers['X-MSMail-Priority'] = 'Low';
break;
case SIMPLENEWS_PRIORITY_LOWEST:
$headers['Priority'] = 'non-urgent';
$headers['X-Priority'] = '5';
$headers['X-MSMail-Priority'] = 'Lowest';
break;
}
// Add user specific header data.
$headers['From'] = $this
->getFromFormatted();
$headers['List-Unsubscribe'] = '<' . \Drupal::token()
->replace('[simplenews-subscriber:unsubscribe-url]', $this
->getTokenContext(), array(
'sanitize' => FALSE,
)) . '>';
// Add general headers
$headers['Precedence'] = 'bulk';
return $headers;
}