{"id":3467,"date":"2021-08-15T18:20:04","date_gmt":"2021-08-15T09:20:04","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=3467"},"modified":"2024-01-12T19:31:47","modified_gmt":"2024-01-12T10:31:47","slug":"post-3467","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/3467","title":{"rendered":"SendGrid\u3092\u4f7f\u3063\u3066\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u305b\u305a\u306bPHP\u304b\u3089\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u305b\u305a\u306b\u72ec\u81ea\u30c9\u30e1\u30a4\u30f3\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3092\u884c\u3044\u305f\u3044\u3002\u904e\u53bb\u306b<a href=\"https:\/\/taitan916.info\/blog\/archives\/1830\" target=\"_blank\" rel=\"noopener\">Gmail\u306eSTPT\u30b5\u30fc\u30d0\u7d4c\u7531\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u3059\u308b\u65b9\u6cd5<\/a>\u3092\u30e1\u30e2\u3057\u305f\u304c\u3001\u3053\u306e\u65b9\u6cd5\u3060\u3068\u9001\u4fe1\u5143\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u5f53\u7136Gmail\u30a2\u30c9\u30ec\u30b9\u306b\u306a\u308b\u3002\u4f55\u304b\u65b9\u6cd5\u306f\u7121\u3044\u304b\u8abf\u3079\u3066\u307f\u308b\u3068<a href=\"https:\/\/sendgrid.kke.co.jp\/\" target=\"_blank\" rel=\"noopener\">SendGrid<\/a>\u3068\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u304c\u7c21\u5358\u306b\u5b9f\u88c5\u3067\u304d\u305f\u3002\u4ee5\u4e0b\u306b\u5bfe\u5fdc\u65b9\u6cd5\u3092\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>SendGrid<\/h2>\n<h3>SendGrid\u3068\u306f<\/h3>\n<p>SendGrid\u3068\u306f\u30af\u30e9\u30a6\u30c9\u30d9\u30fc\u30b9\u306e\u30e1\u30fc\u30eb\u914d\u4fe1\u30b5\u30fc\u30d3\u30b9\u3067\u3042\u308a\u3001\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u305b\u305a\u3068\u3082API\u3084SMTP\u7d4c\u7531\u3067\u30e1\u30fc\u30eb\u9001\u4fe1\u304c\u53ef\u80fd\u3002\u307e\u305f\u3001\u8ff7\u60d1\u30e1\u30fc\u30eb\u5224\u5b9a\u3055\u308c\u306b\u304f\u3044\u3063\u307d\u3044(\u904e\u53bb\u306b\u901a\u5e38\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u3060\u3068\u8ff7\u60d1\u30e1\u30fc\u30eb\u5224\u5b9a\u3055\u308c\u305f\u306e\u306bSendGrid\u7d4c\u7531\u3060\u3068\u8ff7\u60d1\u30e1\u30fc\u30eb\u5224\u5b9a\u3055\u308c\u306a\u3044\u3068\u3044\u3046\u30b1\u30fc\u30b9\u304c\u3042\u3063\u305f)\u3002<\/p>\n<p>\u5c1a\u3001<a href=\"https:\/\/sendgrid.kke.co.jp\/plan\/\" target=\"_blank\" rel=\"noopener\">12,000\u901a\/\u6708\u307e\u3067\u306f\u7121\u6599<\/a>\u3067\u5229\u7528\u3067\u304d\u308b\u3002<\/p>\n<h3>\u30a2\u30ab\u30a6\u30f3\u30c8\u767b\u9332<\/h3>\n<p><a href=\"https:\/\/sendgrid.kke.co.jp\/app?p=signup.index\" target=\"_blank\" rel=\"noopener\">\u65b0\u898f\u767b\u9332\u30da\u30fc\u30b8<\/a>\u3088\u308a\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u767b\u9332\u3059\u308b\u3002\u5c1a\u3001\u30a2\u30ab\u30a6\u30f3\u30c8\u306f\u5373\u6642\u767a\u884c\u3067\u306f\u306a\u304f\u3001\u7fcc\u55b6\u696d\u65e5\u7b49\u306b\u767a\u884c\u3055\u308c\u308b\u70b9\u306b\u6ce8\u610f\u3059\u308b\u3002<\/p>\n<h3>SMTP\u7528\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u767a\u884c<\/h3>\n<p><a href=\"https:\/\/sendgrid.kke.co.jp\/app?p=login.index\" target=\"_blank\" rel=\"noopener\">\u30ed\u30b0\u30a4\u30f3\u30da\u30fc\u30b8<\/a>\u3088\u308a\u30ed\u30b0\u30a4\u30f3\u3057\u3001\u5de6\u5074\u306e\u30e1\u30cb\u30e5\u30fc\u306e\u300cEmail API\u2192Integration Guide\u2192SMTP Relay\u306eChoose\u300d\u306b\u9032\u307f\u300cAPI Key Name\u300d\u3092\u5165\u529b\u3057\u3001\u300cCreate Key\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u767a\u884c\u3055\u308c\u308b\u3002<\/p>\n<p>\u5c1a\u3001\u30db\u30b9\u30c8\u306f\u300csmtp.sendgrid.net\u300d\u3001\u30e6\u30fc\u30b6\u540d\u306f\u300capikey\u300d\u306b\u306a\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"PHPMailer\">PHPMailer\u306e\u6e96\u5099<\/span><\/h2>\n<p>\u4ee5\u4e0b\u3088\u308a\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u5c55\u958b\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/PHPMailer\/PHPMailer\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/PHPMailer\/PHPMailer<\/a><\/p>\n<p>src\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u300cPHPMailer.php\u300d\u300cException.php\u300d\u300cSMTP.php\u300d\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3002\u3082\u3057\u304f\u306fsrc\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3054\u3068\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3067\u3082\u826f\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n\r\nrequire('.\/PHPMailer.php');\r\nrequire('.\/Exception.php');\r\nrequire('.\/SMTP.php');\r\n\r\n\/\/ \u6587\u5b57\u30a8\u30f3\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\r\nmb_language('uni');\r\nmb_internal_encoding('UTF-8');\r\n\r\n\/\/ \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\uff08true\u6307\u5b9a\u3067\u4f8b\u5916\u3092\u6709\u52b9\u5316\uff09\r\n$mail = new PHPMailer\\PHPMailer\\PHPMailer();\r\n\r\ntry {\r\n\r\n    $host = 'smtp.sendgrid.net';\r\n    $username = 'apikey'; \r\n    $password = '\u30d1\u30b9\u30ef\u30fc\u30c9';\r\n\r\n    \/\/\u5dee\u51fa\u4eba\r\n    $from = '\u5dee\u51fa\u4eba\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9';\r\n    $fromname = '\u5dee\u51fa\u4eba\u540d';\r\n\r\n    \/\/\u5b9b\u5148\r\n    $to = '\u5b9b\u5148\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9';\r\n    $toname = $to;\r\n\r\n    \/\/\u4ef6\u540d\u30fb\u672c\u6587\r\n    $subject = 'subject';\r\n    $body = 'body';\r\n\r\n    \/\/\u30e1\u30fc\u30eb\u8a2d\u5b9a\r\n    $mail-&gt;SMTPDebug = 0; \/\/\u30c7\u30d0\u30c3\u30b0\u7528\r\n    $mail-&gt;isSMTP();\r\n    $mail-&gt;SMTPAuth = true;\r\n    $mail-&gt;Host = $host;\r\n    $mail-&gt;Username = $username;\r\n    $mail-&gt;Password = $password;\r\n    $mail-&gt;SMTPSecure = 'tls';\r\n    $mail-&gt;Port = 587;\r\n    $mail-&gt;CharSet = \"utf-8\";\r\n    $mail-&gt;Encoding = \"base64\";\r\n    $mail-&gt;setFrom($from, $fromname);\r\n    $mail-&gt;addAddress($to, $toname);\r\n    $mail-&gt;Subject = $subject;\r\n    $mail-&gt;Body\t\t= $body;\r\n\r\n    \/\/\u30e1\u30fc\u30eb\u9001\u4fe1\r\n    $mail-&gt;send();\r\n    \r\n    \/\/\u9001\u4fe1\u6210\u529f\u6642\u306e\u51e6\u7406\r\n\r\n} catch (Exception $e) {\r\n\r\n    \/\/\u9001\u4fe1\u5931\u6557\u6642\u306e\u51e6\u7406\r\n\r\n}<\/pre>\n<p>\u5404\u7a2e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u90e8\u5206\u306f\u9069\u5b9c\u5909\u66f4\u3059\u308b\u3002\u5c1a\u3001\u9001\u4fe1\u5143\u30a2\u30c9\u30ec\u30b9\u3067\u3042\u308b\u30c9\u30e1\u30a4\u30f3\u306eSPF\u30ec\u30b3\u30fc\u30c9\u3084MX\u30ec\u30b3\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u306a\u304f\u3066\u3082\u9001\u4fe1\u304c\u78ba\u8a8d\u3067\u304d\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u6240\u611f<\/h2>\n<p>\u79c1\u7684\u306b\u30b5\u30fc\u30d0\u95a2\u9023\u306e\u4e2d\u3067\u3082\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u306b\u95a2\u3057\u3066\u306f\u82e6\u624b\u610f\u8b58\u304c\u3042\u3063\u305f\u70ba\u3001\u4eca\u56de\u306e\u3088\u3046\u306a\u9001\u4fe1\u65b9\u6cd5\u3092\u77e5\u308c\u305f\u306e\u306f\u826f\u304b\u3063\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9\u305b\u305a\u306b\u72ec\u81ea\u30c9\u30e1\u30a4\u30f3\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u3066\u30e1\u30fc\u30eb\u9001\u4fe1\u3092\u884c\u3044\u305f\u3044\u3002\u904e ... <\/p>\n","protected":false},"author":1,"featured_media":1085,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[90],"class_list":["post-3467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-phpmailer"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=3467"}],"version-history":[{"count":0,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3467\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/1085"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=3467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=3467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=3467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}