Permalink
Browse files

fixed fatal errors when no To or Subject header has been set

  • Loading branch information...
1 parent 05b0cab commit 476586b810a98d06be477fd01c4309c74993e1b4 @fabpot fabpot committed Sep 1, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/classes/Swift/Transport/MailTransport.php
@@ -126,8 +126,14 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
$toHeader = $message->getHeaders()->get('To');
$subjectHeader = $message->getHeaders()->get('Subject');
+ if (!$toHeader)
+ {
+ throw new Swift_TransportException(
+ 'Cannot send message without a recipient'
+ );
+ }
$to = $toHeader->getFieldBody();
- $subject = $subjectHeader->getFieldBody();
+ $subject = $subjectHeader ? $subjectHeader->getFieldBody() : '';
$reversePath = $this->_getReversePath($message);

0 comments on commit 476586b

Please sign in to comment.