1
0
Fork 0
mirror of synced 2024-06-29 03:30:34 +12:00
appwrite/app/workers/mails.php
2020-06-20 14:20:49 +03:00

49 lines
1 KiB
PHP

<?php
require_once __DIR__.'/../init.php';
\cli_set_process_title('Mails V1 Worker');
echo APP_NAME.' mails worker v1 has started';
class MailsV1
{
/**
* @var array
*/
public $args = [];
public function setUp()
{
}
public function perform()
{
global $register;
$event = $this->args['event'];
$recipient = $this->args['recipient'];
$name = $this->args['name'];
$subject = $this->args['subject'];
$body = $this->args['body'];
$mail = $register->get('smtp'); /* @var $mail \PHPMailer\PHPMailer\PHPMailer */
$mail->addAddress($recipient, $name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = \strip_tags($body);
try {
$mail->send();
} catch (\Exception $error) {
throw new Exception('Error sending mail: ' . $error->getMessage(), 500);
}
}
public function tearDown()
{
// ... Remove environment for this job
}
}