我试图找到一种更简单的方法,使用我们的数据库(MySQL)向所有客户发送电子邮件。我想知道是否有一种方法可以选择我客户的所有电子邮件,我可以添加消息,主题并从我的网站发送给我的所有客户,而不是复制每封邮件。
有没有办法集成SMTP来执行此操作?使用PHP或javascript。
感谢。
答案 0 :(得分:3)
是的,大概有5,247种方式。见这些:
这些都很好(而不是唯一的)。您可以选择最适合您目的的那个,没有“单一最佳”库。
答案 1 :(得分:0)
我使用SwiftMailer ..它对我有用。
* Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own
* Support servers that require username & password and/or encryption
* Protect from header injection attacks without stripping request data content
* Send MIME compliant HTML/multipart emails
* Use event-driven plugins to customize the library
* Handle large attachments and inline/embedded images with low memory use
require_once 'lib/swift_required.php';
//Create the Transport
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
//Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
->setBody('Here is the message itself')
;
//Send the message
$numSent = $mailer->batchSend($message);
printf("Sent %d messages\n", $numSent);
/* Note that often that only the boolean equivalent of the
return value is of concern (zero indicates FALSE)
if ($mailer->batchSend($message))
{
echo "Sent\n";
}
else
{
echo "Failed\n";
}