-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbulk.php
More file actions
34 lines (28 loc) · 1.11 KB
/
bulk.php
File metadata and controls
34 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
# src/Command/SendBulkMailCommand.php
# php bin/console app:send-bulk-mail
namespace App\Command;
use Mailtrap\Helper\ResponseHelper;
use Mailtrap\MailtrapClient;
use Mailtrap\Mime\MailtrapEmail;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Mime\Address;
#[AsCommand(name: 'app:send-bulk-mail')]
final class SendBulkMailCommand
{
public function __invoke(): int { // Available since Symfony 7.0. For earlier versions, use the execute() method instead.
$email = (new MailtrapEmail())
->from(new Address('hello@example.com', 'Mailtrap Transactional'))
->to(new Address("email@gmail.com"))
->subject('You are awesome!')
->text('Congrats for sending email with Mailtrap!')
;
$response = MailtrapClient::initSendingEmails(
apiKey: $_ENV['MAILTRAP_API_KEY'], // your API token from here https://mailtrap.io/api-tokens
isBulk: true
)->send($email);
var_dump(ResponseHelper::toArray($response));
return Command::SUCCESS;
}
}