1. Go to this page and download the library: Download myth/postal 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/ */
myth / postal example snippets
use Myth\Postal\Email;
$email = (new Email())
->from('[email protected]', 'Your Name')
->to('[email protected]')
->subject('Welcome aboard')
->html('<p>Glad to have you with us.</p>');
$result = service('mailer')->send($email);
if ($result->success) {
log_message('info', 'Sent message ' . $result->messageId);
}
service('mailer')->mailer('ses')->send($email); // use the 'ses' mailer for this send
use Myth\Postal\Mailable;
class WelcomeEmail extends Mailable
{
public function __construct(private User $user)
{
parent::__construct();
}
protected function build(): void
{
$this->to($this->user->email)
->subject('Welcome aboard')
->html(view('emails/welcome', ['user' => $this->user]));
}
}
(new WelcomeEmail($user))->send();