daniel-zahariev / php-aws-ses

PHP classes that interfaces Amazon Simple Email Service
307 stars 100 forks source link

Sending email async #42

Closed johnswyen closed 7 years ago

johnswyen commented 7 years ago

Is it possible to send email asynchronously? this is the code snippet we have.

====================THIS IS CALLER======================== $silent = '> /dev/null 2>/dev/null &'; $data = ... $d = json_encode($data); $payload = base64_encode($d); exec("php {$_SERVER['DOCUMENT_ROOT']}/class/do_sendmail.php \"$payload\" $silent");`

====================THIS IS CALLEE======================== // do_sendmail.php $m = new SimpleEmailServiceMessage(); $m->setFrom($d->from); $m->addTo($d->to); $m->addCC($d->cc); $m->addBCC($d->bcc); $m->setSubject($d->subject); $m->setMessageFromString(strip_tags($d->content), $d->content); $ses = new SimpleEmailService(AWS_SES_API_KEY, AWS_SES_API_SEC); $ses->sendEmail($m,true);

By using '> /dev/null 2>/dev/null &' together with exec() we can do async curl to other http request successfully. But when we switch to SimpleEmailService, it doesn't work as excepted.

daniel-zahariev commented 7 years ago

Hi @johnswyen, have you tested it in sync mode? What error do you get?