phplibrary/src/MailAlt.php

99 lines
1.8 KiB
PHP

<?php
namespace ctiso;
use PHPMailer\PHPMailer\PHPMailer;
class MailAlt
{
public $mailer;
public $_notify;
public $encoding;
function __construct() {
$this->mailer = new PHPMailer();
$this->mailer->CharSet = 'UTF-8';
}
/**
* Установка отправителя
*/
function from($name)
{
$this->mailer->setFrom($name);
}
/**
* Установка получателя
*/
function to($name) // recipient
{
$this->mailer->addAddress($name);
}
function replyTo($name) // recipient
{
$this->mailer->AddReplyTo($name);
}
/**
* Установка получателей копии
*/
function copy($name) // recipient cc
{
$this->mailer->addCC($name);
}
function notify($notify)
{
$this->_notify = $notify;
}
/**
* Тема письма
*/
function subject($subject/*: string*/)
{
$this->mailer->Subject = $subject;
}
/**
* Текст письма
*/
function setContent($text)
{
$this->mailer->Body = $text;
}
function setType($text)
{
$this->mailer->isHTML($text == 'text/html');
}
/**
* Кодировка текста в письме
*/
function setEncoding($encoding)
{
$this->encoding = $encoding;
}
/**
* Добавление вложения из файла
*/
function addAttachment($filename, $name = null)
{
$this->mailer->addAttachment($filename, $name);
}
/**
* Отправка почты
*/
function send()
{
return $this->mailer->send();
}
function eml() {
return $this->mailer->getSentMIMEMessage();
}
}