PHPバージョン5.6
フレームワーク等は使用しておりません。
現在メール配信をSendGridを使用して行うことを
検討しております。
こちらのサイトの皆様のお力添えにより、複数の宛先
に送信する方法は解決致しました。
【SendGridを使用して複数の宛先にメールを配信する方法】
https://teratail.com/questions/128834
しかし、複数のメールを送る際にtoで送信すると、全ての
メールアドレスが他の人にも見えるため、Bccで送信をしようかと
考えております。
そこでご質問ですが、一度の宛先が100件~500件程度の場合
Bccで送信する方が良いのか、foreach等で下記のようなプログラムを
回す方が良いのかどちらが負荷がかるいでしょうか。
それぞれの良し悪しが在りそうで、悩んでおります。
皆様のご意見をお聞かせ頂ければと思います。
宜しくお願い致します。
php
1 2require 'vendor/autoload.php'; // If you're using Composer (recommended) 3// comment out the above line if not using Composer 4// require("./sendgrid-php.php"); 5// If not using Composer, uncomment the above line 6$email = new \SendGrid\Mail\Mail(); 7$email->setFrom("test@example.com", "Example User"); 8$tos = [ "test+test1@example.com" => "Example User1"]; 9$email->addTo($tos); 10$email->setSubject("Sending with SendGrid is Fun"); 11$email->addContent("text/plain", "and easy to do anywhere, even with PHP"); 12$email->addContent( 13 "text/html", "<strong>and easy to do anywhere, even with PHP</strong>" 14); 15$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY')); 16try { 17 $response = $sendgrid->send($email); 18 print $response->statusCode() . "\n"; 19 print_r($response->headers()); 20 print $response->body() . "\n"; 21} catch (Exception $e) { 22 echo 'Caught exception: ', $e->getMessage(), "\n"; 23}
あなたの回答
tips
プレビュー