我有用户的数据库给谁,我想发送相同的电子邮件。我正在使用Mandrill来发送电子邮件。网站的管理员必须输入电子邮件的主题,消息和附件,然后将其提交给所有订阅者。发送多封电子邮件与山魈
我已经试过这样做,运行在数据库中的每封电子邮件的山魈API while循环。它可以工作,但服务器在发送大约5封电子邮件后会耗尽并崩溃。
我也知道,要能运行一次山魈API和发送多封电子邮件,山魈API中的“到”数组必须重复每一个电子邮件地址。我试图做的事情是让某种重复的循环为山魈API中的每封电子邮件的“到”阵列,从而运行整个API一次发送的所有电子邮件。以下是我用来发送电子邮件的Mandrill API。
你们可以帮助,请帮助我吗?
感谢
while($row = mysqli_fetch_assoc($result1))
{
$ID = $row['ID'];
$name = $row['name'];
$surname = $row['surname'];
$email = $row['email'];
try
{
$mandrill = new Mandrill('My Key');
$message = array(
'html' => $message,
'subject' => $subject,
'from_email' => '[email protected]',
'from_name' => 'Silvan Theuma',
'to' => array(
array(
'email' => $email,
'name' => $name,
'type' => 'to'
)
),/*This is what I want to repeat for every email*/
'attachments' => array(
array(
'type' => $mimeType,
'name' => $attachmentName,
'content' => $file_encoded
)
),
);
$async = false;
$ip_pool = 'Main Pool';
$result = $mandrill->messages->send($message, $async, $ip_pool);
}
catch(Mandrill_Error $e)
{
// Mandrill errors are thrown as exceptions
echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
// A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
throw $e;
}
}
你使用的是什么山魈库? –
我正在使用从他们的网站 – user3697612