Send bulk email in background from PHP to Go. No additional setup like Queuing service.
You can install phptogo-mailer
using go get
:
go get -u github.com/ljfreelancer88/phptogo-mailer@latest
go test -v
This is just a simple usage. Basically, (1)PHP will just prepare all data needed and (2)pass it to Go binary.
#1 Prepare all data needed
$from = 'Collideborate Team';
$subject = 'John 3:16 song has been added!';
// Fetch rocords from the database.
$recipients = json_encode([
["Name" => "Jake", "Email" => "[email protected]"],
["Name" => "Admin", "Email" => "[email protected]"]
]);
$mailerDir = '/cli/phptogo-mailer'; // Where phptogo-mailer compiled binary lives
$mail = "{$mailerDir}/main"; // Compiled binary
$log = " >> {$mailerDir} mailer.log 2>&1 &"; // Log it and do the task in background
#2 Pass it to Go binary
passthru(
sprintf(
$mail . " --from %s --subject %s --recipients %s" . $log,
escapeshellarg($from),
escapeshellarg($subject),
escapeshellarg($recipients)
)
);
If you want to do it directly on your terminal and skip PHP.
/cli/phptogo-mailer/main --from "Collideborate Team" --subject "John 3:16 song has been added!" --recipients '[{"Name": "Jake", "Email": "[email protected]"}, {"Name": "Admin", "Email": "[email protected]"}]'
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.