1. Go to this page and download the library: Download lazervel/mailsender 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/ */
lazervel / mailsender example snippets
azervel\MailSender\MailSender;
$mail = new MailSender(
name: 'My App',
email: '[email protected]',
password: 'yourpassword'
);
// Single recipient
$mail->addMail('John Doe', '[email protected]');
$mail->mail->Subject = 'Welcome!';
$mail->mail->Body = '<h1>Hello John!</h1><p>Welcome to our app.</p>';
// Send
if ($mail->send()) {
echo "Mail sent successfully!";
} else {
echo "Failed to send mail!";
}
$recipients = [
[
'name' => 'User One',
'email' => '[email protected]',
'subject' => 'Hello!',
'body' => '<p>This is a test email.</p>'
],
[
'name' => 'User Two',
'email' => '[email protected]',
'subject' => 'Another Mail',
'body' => '<p>This is another email.</p>'
]
];
$mail->sendTo($recipients)->send();