6
私はMandrillでテンプレートを作成しましたが、メールの送信方法はわかりません。テンプレートを使ってメールを送信する(Mandrill PHP)
<?php
include_once "swift_required.php";
$subject = 'Hello from Mandrill, PHP!';
$from = array('[email protected]' =>'Your Name');
$to = array(
'[email protected]' => 'Recipient1 Name',
'[email protected]' => 'Recipient2 Name'
);
$text = "Mandrill speaks plaintext";
$html = "<em>Mandrill speaks <strong>HTML</strong></em>";
$transport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587);
$transport->setUsername('MANDRILL_USERNAME');
$transport->setPassword('MANDRILL_PASSWORD');
$swift = Swift_Mailer::newInstance($transport);
$message = new Swift_Message($subject);
$message->setFrom($from);
$message->setBody($html, 'text/html');
$message->setTo($to);
$message->addPart($text, 'text/plain');
if ($recipients = $swift->send($message, $failures))
{
echo 'Message successfully sent!';
} else {
echo "There was an error:\n";
print_r($failures);
}
?>
ありがとう、働いているだけです。$ mandrill = new Mandrill( 'YOUR_API_KEY'); – Marckaraujo
もう1つの情報、私は* htmlテンプレートの中に* pspReference | *を設定しました。そしてmerge_varsには 'name' => 'pspReference'、 'content' => 'Hello world'価値、あなたはなぜ知っていますか?ありがとう – Marckaraujo
@Marckaraujoはあなたのテンプレートがどのように見えるかを表示できますか? – MrCode