PHP code example of phpdot / mail
1. Go to this page and download the library: Download phpdot/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/ */
phpdot / mail example snippets
use PHPdot\Mail\Contract\MailerInterface;
final class Welcome
{
public function __construct(private readonly MailerInterface $mail) {}
public function greet(string $email): string
{
$receipt = $this->mail
->to($email, 'Alice')
->subject('Welcome aboard')
->html('<h1>Hi Alice</h1>')
->text('Hi Alice')
->send();
return $receipt->messageId; // '<[email protected]>'
}
}
$base = $mail->message()->from('[email protected]', 'Acme')->replyTo('[email protected]');
$base->to('[email protected]')->subject('Hi')->send();
$base->to('[email protected]')->subject('Hi')->send(); // $base is untouched