Skip to content

Commit

Permalink
Prevent emails to empty 'to' address
Browse files Browse the repository at this point in the history
  • Loading branch information
mfairchild365 committed Nov 4, 2015
1 parent eb52a9d commit 557f089
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/UNL/VisitorChat/Conversation/Email.php
Expand Up @@ -187,14 +187,18 @@ public function generateHeaders()

public function send()
{
$to_string = $this->generateToString();

//can we send to anyone?
if (empty($this->to_emails)) {
if (empty($to_string)) {
//Nope. Can't find anyone to send emails to... so send to the fallback list otherwise return false
if (empty(self::$fallbackEmails) || !is_array(self::$fallbackEmails)) {
return false;
}

$this->setTo(self::$fallbackEmails);

$to_string = $this->generateToString();
}

$text = $this->render('textemail');
Expand All @@ -207,7 +211,7 @@ public function send()
$body = $mime->get();
$headers = $mime->headers($this->generateHeaders());

if (\UNL\VisitorChat\Controller::$mailService->send($this->generateToString(), $headers, $body)) {
if (\UNL\VisitorChat\Controller::$mailService->send($to_string, $headers, $body)) {
return Email\Record::recordSentEmail($headers['To'], $headers['From'], $headers['Reply-To'], $headers['Subject'], $this->fromId, $this->conversation->id);
}

Expand Down

0 comments on commit 557f089

Please sign in to comment.