1. Go to this page and download the library: Download zeus/email 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/ */
zeus / email example snippets
use Zeus\Email\CommandSender;
use Zeus\Email\SmtpAuthenticator;
p.io",
"your_username",
"your_password",
2525,
10,
[
"ssl" => [
"verify_peer" => false,
"verify_peer_name" => false,
"allow_self_signed" => true
]
]
);
Mail::setSmtpAuthenticator($smtpAuthenticator); // Set it once
class WelcomeMail implements EmailFactoryInterface
{
public function build(EmailBuilder $builder): void
{
$builder->setSubject("Welcome to Our Website");
$builder->setHtmlBody('<html><body><h1>Welcome!</h1><p>This is a test email with an attachment.</p></body></html>');
$builder->addCc('[email protected]');
$builder->addBcc('[email protected]');
$builder->setReplyTo('[email protected]');
$builder->addAttachment(__FILE__);
}
}
$response = Mail::to('[email protected]')
->from('[email protected]')
->send(new Payment());
if ($response) {
echo "✅ Email sent successfully";
} else {
echo "❌ Failed to send email";
}
class Logger implements \Zeus\Email\EmailLogInterface
{
public function log(string $message,int $level)
{
//log operations
}
}
$mail = Mail::to('[email protected]');
$mail->from('[email protected]')
->logTo(new Logger())
->beforeSend(function (EmailBuilder $builder) {
$builder->addCc('[email protected]');
})
->afterSend(function () {
//trigger an event
})
->send(new Payment());
class Payment implements EmailFactoryInterface
{
/**
* @throws Exception
*/
public function build(EmailBuilder $builder): void
{
$builder->setSubject("Welcome to Our Website");
$builder->setBody('Test a message');
$builder->scheduleAt(new DateTime('last day of this month'));
}
}