Closed morrow95 closed 4 years ago
hi @morrow95 ,
when the bulk mode is enabled (via $ses->setBulkMode(true);
) then only one curl handler is used to send all messages. The message object doesn't need to be reused as it is in your example.
Hope this makes sense.
Creating message object doesn't affect how it is sent as you can have multiple instances of SimpleEmailService which use different AWS hosts.
hi @morrow95 , when the bulk mode is enabled (via $ses->setBulkMode(true);) then only one curl handler is used to send all messages. The message object doesn't need to be reused as it is in your example. Hope this makes sense.
Sorry, I'm not following what you mean. You say I don't have to reuse the message object, but the loop is what sends out to each email address I want. I guess I need an example and/or better explanation of what is going on here with the bulk mode.
From your code example: $ses
is an instance of SimpleEmailService
class which handles the actual request to AWS and when the bulk mode is enabled it reuses the curl handler. On the other hand there's the $m
variable which is an instance of SimpleEmailServiceMessage
it can be created inside the loop and doesn't have anything to do with the bulk mode.
I'm sorry... I'm still not following you here mainly because I don't know how you are implementing this bulk mode setting. Maybe an example of what you are talking about would be a better way to approach this? You say I don't have to reuse the message object as I do in my example, but how else would you send out to multiple email addresses then?
I found out in the past that I needed to use $m->clearTo(); or else there would be multiple recipients on each send - they would just accumulate. Or is that what the bulk mode setting actually does... you $ses->sendEmail($m); once and each email is sent out one by one?
@morrow95 i must apologise. I've forgot that i've deprecated the bulk mode because now the default behaviour is to reuse the curl handler which is managed in SimpleEmailServiceRequest class.
So you can simply iterate over the target emails and create a message for every one of them:
foreach($results as $value)
{
$m = new SimpleEmailServiceMessage();
$m->setFrom('no-reply@example.com');
$m->addReplyTo('no-reply@example.com');
$m->setSubject('some subject');
$m->addTo($value['account_email']);
$m->setMessageFromString($out_text, $out_html);
$ses->sendEmail($m);
}
Hope this clarifies it enough.
@daniel-zahariev Okay. I just want to point out that SimpleEmailService.php has plenty of references to the bulk mode still so if it doesn't serve a purpose then maybe that should be cleaned up.
Trying to better understand how the bulk mode works. I wrote a script to send out bulk emails for a newsletter, each with a different email address, so not sure if I am taking advantage of the bulk mode here or not. Here is an example of what I am doing :
Is this actually taking advantage of the bulk sending or not? There really isn't much information on it. If it reuses the curl handler when this is set then is there any reason this just isn't the default and enabled whenever
$m = new SimpleEmailServiceMessage();
is called?