开发者

batch email send with custom content

I want to send out batch mails using SwiftMailer but just wondering what the best option for this w开发者_如何学Could be. The problem is the email content needs to be customized, i.e. there will be a salutation at the top, and a custom link.

Here is my current OOP code:

foreach($suppliers as $supplier)
{
    $quote=new Quote();
    $quote->enquiry_id=$enquiry->id;
    $quote->supplier_id=$supplier->id;

    if($quote->save())
    {
        $supplier_emails[]=$supplier->email;
    }
}

$message=new SwiftMailMessage;
$message->setTo($supplier_emails);
$message->setFrom($params['adminEmailFromAddress'] => $params['adminEmailFromName']);
$message->setBody('Here is the message itself')
App::app()->mail->batchSend($message);

I am using a container for SwiftMailer. So as you can see, I can easily specify an array of email address to send the message to. How can I now customize the content? The variables I need to include in the content are $supplier->name and $supplier->link.

Personally I can't see how this can be done, other than sending each email individually in the foreach() loop. IF that is the case, then is it not better to just use the internal PHP mail() function?


You could try using the Decorator plugin:

http://swiftmailer.org/docs/decorator-plugin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜