Skip to content

InitPHP/Mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailer

Mailer Class

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Instalation

composer require initphp/mailer

Requirements

  • PHP 7.4 or higher
  • MBString Extension
  • Iconv Extension
  • FileInfo Extension

Usage

$config = [
    'mailType'  => 'text' // or 'html'
    'protocol'  => 'smtp' // or 'mail' or 'sendmail'
    'SMTPAuth'  => true,
    'SMTPHost'  => 'smtp.gmail.com',
    'SMTPUser'  => '[email protected]',
    'SMTPPass'  => 'YourMailPassword',
    'SMTPPort'  => 587
];
$mailer = \InitPHP\Mailer\Mailer::newInstance($config);

$mailer->setFrom('[email protected]', 'Muhammet Şafak');
//$mailer->setTo('[email protected]');
//$mailer->setCC('[email protected]');
//$mailer->setBCC('[email protected]');
$mailer->setSubject('Mail Subject');
$mailer->setMessage('Mail Body Message');
$mailer->send();

Methods

newInstance()

Creates a new mailer object and returns it.

public static function newInstance(?array $config = null): \InitPHP\Mailer\Mailer

clear()

public function clear(bool $clearAttachments = false): self

setHeader()

public function setHeader(string $header, string $value): self

setFrom()

public function setFrom(string $from, string $name = '', ?string $returnPath = null): self

setReplyTo()

public function setReplyTo(string $replyTo, string $name = ''): self

setTo()

public function setTo(string|array $to): self

setCC()

public function setCC(string $cc): self

setBCC()

public function setBCC(string $bcc, ?int $limit = null): self

setSubject()

public function setSubject(string $subject): self

setMessage()

public function setMessage(string $body): self

setAttachmentCID()

public function setAttachmentCID(string $fileName): false|string

setAltMessage()

public function setAltMessage(string $str): self

setMailType()

public function setMailType(string $type = 'text'): self
  • $type : text or html

setWordWrap()

public function setWordWrap(bool $wordWrap = true): self

setProtocol()

public function setProtocol(string $protocol = 'mail'): self
  • $protocol : mail, sendmail or smtp

setPriority()

public function setPriority(int $n = 3): self
  • $n : An integer between 1 and 5 inclusive.

setNewline()

public function setNewline(string $newLine = \PHP_EOL): self

setCRLF()

public function setCRLF(string $CRLF = \PHP_EOL): self

attach()

public function attach(string|resource $file, string $disposition = '', ?string $newName = null, ?string $mime = null): false|self

send()

public function send(bool $autoClear = true): bool

printDebugger()

public function printDebugger(array $include = ['headers', 'subject', 'body']): string

Credits

License

Copyright © 2022 MIT License

About

This is a simple and fast library for sending mail with PHP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages