1. Go to this page and download the library: Download tourze/smtp-mailer-bundle 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/ */
tourze / smtp-mailer-bundle example snippets
// 注入服务
use Tourze\SMTPMailerBundle\Service\SMTPMailerService;
class MyController extends AbstractController
{
public function sendEmail(SMTPMailerService $mailerService)
{
$mailerService->send(
'[email protected]',
'邮件主题',
'邮件内容',
[
'from' => '[email protected]',
'isHtml' => true,
'cc' => ['[email protected]'],
]
);
// 或者安排稍后发送
$mailerService->send(
'[email protected]',
'定时邮件',
'这是一封定时发送的邮件',
[
'scheduledAt' => new \DateTime('+1 hour')
]
);
}
}