Jobby\Helper::sendMail PHP Method

sendMail() public method

public sendMail ( string $job, array $config, string $message ) : Swift_Message
$job string
$config array
$message string
return Swift_Message
    public function sendMail($job, array $config, $message)
    {
        $host = $this->getHost();
        $body = <<<EOF
{$message}

You can find its output in {$config['output']} on {$host}.

Best,
jobby@{$host}
EOF;
        $mail = \Swift_Message::newInstance();
        $mail->setTo(explode(',', $config['recipients']));
        $mail->setSubject("[{$host}] '{$job}' needs some attention!");
        $mail->setBody($body);
        $mail->setFrom([$config['smtpSender'] => $config['smtpSenderName']]);
        $mail->setSender($config['smtpSender']);
        $mailer = $this->getCurrentMailer($config);
        $mailer->send($mail);
        return $mail;
    }

Usage Example

Example #1
0
 /**
  * @param string $message
  */
 protected function mail($message)
 {
     if (empty($this->config['recipients'])) {
         return;
     }
     $this->helper->sendMail($this->job, $this->config, $message);
 }
All Usage Examples Of Jobby\Helper::sendMail