PHP code example of initphp / mailer

1. Go to this page and download the library: Download initphp/mailer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

initphp / mailer example snippets


$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();

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

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

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

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

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

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

public function setCC(string $cc): self

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

public function setSubject(string $subject): self

public function setMessage(string $body): self

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

public function setAltMessage(string $str): self

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

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

public function setProtocol(string $protocol = 'mail'): self

public function setPriority(int $n = 3): self

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

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

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

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

public function printDebugger(array $