Skip to content

Commit

Permalink
make sendMail return bool, add phpdoc, remove unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Apr 22, 2024
1 parent ed20329 commit 4400a46
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/core/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use Steamy\Model\Client;

/**
* Class for sending mails to clients
* Class for sending mails
*
* Reference: https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
*/
Expand Down Expand Up @@ -66,25 +65,30 @@ public function __construct()
}

/**
* @throws Exception
* @param string $email Gmail address of recipient
* @param string $subject Email subject line
* @param string $html_message Message body as an HTML string
* @param string $plain_message Message as plain text
* @return bool false on error - See the ErrorInfo property for details of the error
* @throws Exception Error when calling addAddress or msgHTML
*/
public function sendMail(string $email, string $subject, $html_message, $plain_message): void
public function sendMail(string $email, string $subject, string $html_message, string $plain_message): bool
{
//Set who the message is to be sent to
$this->mail->addAddress($email);

//Set the subject line
$this->mail->Subject = $subject;

//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
// Read an HTML message body from an external file, convert referenced images to embedded,
// convert HTML into a basic plain-text alternative body
$this->mail->msgHTML($html_message);

//Replace the plain text body with one created manually
// Replace the plain text body with one created manually
$this->mail->AltBody = $plain_message;

//send the message
$this->mail->send();
// Send the message
return $this->mail->send();
}
}

0 comments on commit 4400a46

Please sign in to comment.