1. Go to this page and download the library: Download webiik/mail 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/ */
webiik / mail example snippets
$mail = new \Webiik\Mail\Mail();
// Add PHPMailer
$mail->setMailer(function () {
return new \Webiik\Mail\Mailer\PHPMailer(new \PHPMailer\PHPMailer\PHPMailer());
});
// Create Message
$message = $mail->createMessage();
// Set charset and priority of Message
$message->setCharset('utf-8');
$message->setPriority(3);
// Set Message sender, bounce address and recipients
$message->setFrom('[email protected]', 'Firstname Lastname');
$message->setBounceAddress('[email protected]');
$message->addTo('[email protected]', 'Firstname Lastname');
$message->addReplyTo('[email protected]');
$message->addCc('[email protected]');
$message->addBcc('[email protected]');
// Set Message subject and body
$message->setSubject('Test subject');
$message->setBody('Hello world, this is body of test message.');
$message->setAlternativeBody('Hellow world, this is alternative body of test message.');
// Set Message attachment
$message->addFileAttachment(__DIR__ . '/nice_picture.jpg');
// Send Message
$unsent = $mail->send([$message]);
// Get unsent email addresses
foreach ($unsent as $email) {
// Do something with undelivered email
}
setMailer(callable $factory):void
$mail->setMailer(function () {
return new \Webiik\Mail\Mailer\PHPMailer(new \PHPMailer\PHPMailer\PHPMailer());
});
// CustomMailer.php
declare(strict_types=1);
namespace Webiik\Mail\Mailer;
use Webiik\Mail\Message;
class CustomMailer implements MailerInterface
{
// Your implementation...