私は配列に格納された電子メールのリストを持っています。私はそのリストをループし、Mailgunでそれぞれに電子メールを送りたいと思います。ここでPHP forループ内でMailgunを使用するにはどうしたらいいですか?
は私のスクリプトが
$mgClient = new Mailgun('snipsnip');
$domain = "sandboxe08d52a4dcd247d7a31e3eb6e672ab03.mailgun.org";
$count = count($emails);
for($i = 0; $i < $count; $i++){
$to = $emails[$i];
$mgClient->sendMessage($domain, array(
'from' => 'Markus from StackOverflow <[email protected]>',
'to' => $to,
'subject' => 'Open This Email',
'text' => 'msg'
));
}
ですこれは私が
Fatal error: Uncaught exception 'Mailgun\Connection\Exceptions\MissingRequiredParameters' with message 'The parameters passed to the API were invalid. Check your inputs!' in /home/content/63/11130563/html/sites/paidfor/includes/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:127 Stack trace: #0 /home/content/63/11130563/html/sites/paidfor/includes/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(90): Mailgun\Connection\RestClient->responseHandler(Object(Guzzle\Http\Message\Response)) #1 /home/content/63/11130563/html/sites/paidfor/includes/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(80): Mailgun\Connection\RestClient->post('sandboxe08d52a4...', Array, Array) #2 /home/content/63/11130563/html/sites/paidfor/includes/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(36): Mailgun\Mailgun->post('sandboxe08d52a4...', Array, Array) #3 /home/content/63/11130563/html/sites/paidfor/bag/success/index.php(21): Mailgun\Mailgun->sendMessage('sandboxe08d52a4...', A in /home/content/63/11130563/html/sites/paidfor/includes/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php on line 127
を取得するエラーは、これがMailgunでループのための正しい道ですか?任意のヒント?配列$電子メールの
内容
Array
(
[0] => [email protected]
[1] => [email protected]
)
アップデート:私は、スクリプトは、私は私のmailgunアカウントであるとして、あなたのコードが動作確認した非Gmailのドメイン
投稿されたスニペットの冒頭に「print_r($ emails)」の出力を投稿してください。 –
@JeffPuckettII投稿を –
の下に追加しました。 Gmailドメインのために働く? –