PHP code example of switon / mail
1. Go to this page and download the library: Download switon/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/ */
switon / mail example snippets
use Switon\Core\Attribute\Autowired;
use Switon\Mail\Address;
use Switon\Mail\MailerInterface;
use Switon\Mail\Message;
class NotifyService
{
#[Autowired] protected MailerInterface $mailer;
public function ping(string $to): void
{
$msg = Message::compose()
->from(new Address('[email protected]'))
->to(new Address($to))
->subject('Ping')
->text('Hello.');
$this->mailer->send($msg->get());
}
}