mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-20 07:18:00 -05:00
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\Libraries;
|
|
|
|
use CodeIgniter\Email\Email;
|
|
|
|
class MY_Email extends Email
|
|
{
|
|
private string $default_cc_address = '';
|
|
private string $default_email_address = '';
|
|
private string $default_sender_name = '';
|
|
private string $default_sender_address = '';
|
|
private string $default_bounce_address = '';
|
|
|
|
public function __construct(array $config = [])
|
|
{
|
|
parent::__construct($config);
|
|
}
|
|
|
|
public function sendMail(string $subject, string $body, ?string $to = null, ?string $reply_name = null, ?string $reply_mail = null, ?string $attachment = null): bool
|
|
{
|
|
$this->setReplyTo($reply_mail, $reply_name);
|
|
$this->setFrom($this->default_sender_address, $this->default_sender_name, $this->default_bounce_address);
|
|
$this->setMailtype('html');
|
|
$this->setSubject($subject);
|
|
$this->setMessage($body);
|
|
if ($to === null) {
|
|
$to = $this->default_email_address;
|
|
$this->setCc($this->default_cc_address);
|
|
}
|
|
if ($attachment) {
|
|
$this->attach($attachment);
|
|
}
|
|
$this->setTo($to);
|
|
|
|
return $this->send();
|
|
}
|
|
}
|