{"id":1830,"date":"2014-08-07T16:21:58","date_gmt":"2014-08-07T07:21:58","guid":{"rendered":"http:\/\/taitan916.info\/blog\/?p=1830"},"modified":"2024-01-12T19:31:55","modified_gmt":"2024-01-12T10:31:55","slug":"post-1830","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/1830","title":{"rendered":"\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u30fc\u3092\u69cb\u7bc9\u305b\u305a\u306bGmail\u306eSMPT\u3092\u4f7f\u3063\u3066PHP\u3067\u30e1\u30fc\u30eb\u9001\u4fe1"},"content":{"rendered":"<p>\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u30fc\u304c\u7acb\u3066\u3089\u308c\u306a\u304b\u3063\u305f\u308a\u3001\u7121\u6599\u30b5\u30fc\u30d0\u30fc\u306e\u305f\u3081\u4f7f\u3048\u306a\u304b\u3063\u305f\u308a\u3068\u3044\u3063\u305f\u5834\u5408\u306bGmail\u306eSMTP\u30b5\u30fc\u30d0\u30fc\u3092\u4f7f\u3063\u3066PHP\u3067\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u65b9\u6cd5\u304c\u3042\u3063\u305f\u306e\u3067\u30e1\u30e2\u3002\u307e\u305aphpmailer\u3068\u3044\u3046\u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3046\u306e\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>2024\/01\/12\u8ffd\u8a18<\/h2>\n<p>\u672c\u30da\u30fc\u30b8\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u306f\u9001\u4fe1\u3067\u304d\u306a\u3044\u3002\u65b0\u3057\u304f\u300c<a href=\"https:\/\/taitan916.info\/blog\/archives\/3954\" target=\"_blank\" rel=\"noopener\">PHPMailer\u3067Gmail\u306eSMTP\u30b5\u30fc\u30d0\u3092\u7d4c\u7531\u3057\u3066\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u65b9\u6cd5<\/a>\u300d\u306e\u8a18\u4e8b\u53c2\u7167\u3092\u63a8\u5968\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>PHPMailer<\/strong><\/h2>\n<p><a href=\"http:\/\/phpmailer.worxware.com\/\" target=\"_blank\" rel=\"noopener\">http:\/\/phpmailer.worxware.com\/<\/a><\/p>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u9069\u5f53\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\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\ninclude('.\/PHPMailer.php');\r\ninclude('.\/Exception.php');\r\ninclude('.\/SMTP.php');\r\ndate_default_timezone_set('Asia\/Tokyo');\r\nmb_language(\"japanese\");\r\nmb_internal_encoding(\"UTF-8\");\r\n\/\/Gmail\u30a2\u30ab\u30a6\u30f3\u30c8\r\n$gmail_host = 'smtp.gmail.com';\r\n$gmail_user = '\u3010Gmail\u30a2\u30c9\u30ec\u30b9\u3011';\r\n$gmail_pass = '\u3010\u30a2\u30d7\u30ea\u30d1\u30b9\u30ef\u30fc\u30c9\u3011';\r\n\/\/to\r\n$to = 'to@gmail.com';\r\n\/\/from\r\n$from = 'from@gmail.com';\r\n$from_name = '\u5dee\u51fa\u4eba\u540d';\r\n\/\/\u4ef6\u540d\u3068\u672c\u6587\r\n$subject = '\u4ef6\u540d';\r\n$body = '\u672c\u6587';\r\n\/\/phpmailer\u8a2d\u5b9a\r\n$mail = new PHPMailer\\PHPMailer\\PHPMailer();\r\n$mail-&gt;SMTPDebug = 2; \/\/\u30c7\u30d0\u30c3\u30b0\u7528\r\n$mail-&gt;isSMTP();\r\n$mail-&gt;Host = $gmail_host;\r\n$mail-&gt;Port = 587;\r\n$mail-&gt;SMTPSecure = 'tls';\r\n$mail-&gt;SMTPAuth = true;\r\n$mail-&gt;Username = $gmail_user;\r\n$mail-&gt;Password = $gmail_pass;\r\n$mail-&gt;SMTPOptions = [\r\n    'ssl' =&gt; [\r\n        'verify_peer' =&gt; false\r\n        ,'verify_peer_name' =&gt; false\r\n        ,'allow_self_signed' =&gt; true\r\n    ]\r\n];\r\n$mail-&gt;IsHTML(false);\r\n$mail-&gt;CharSet = \"utf-8\";\r\n$mail-&gt;Encoding = \"base64\";\r\n$mail-&gt;setFrom($from, $from_name);\r\n$mail-&gt;addAddress($to);\r\n$mail-&gt;Subject = $subject;\r\n$mail-&gt;Body = $body;\r\nif( !$mail-&gt;Send() ){\r\n    echo \"\u9001\u4fe1\u5931\u6557&lt;br\/ &gt;\";\r\n    echo \"\u30a8\u30e9\u30fc\u5185\u5bb9: \" . $mail-&gt;ErrorInfo;\r\n} else {\r\n    echo \"\u9001\u4fe1\u6210\u529f\";\r\n}\r\n?&gt;<\/pre>\n<p>\u4e0a\u8a18\u3067\u9001\u4fe1\u3067\u304d\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>2015\/12\/29\u8ffd\u8a18<\/h2>\n<p>include\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u9055\u3046\u3082\u306e\u306b\u5909\u66f4\u3002\u3042\u3068\u672c\u6587\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u3044\u305f\u306e\u3067\u3001class.phpmailer.php\u306e48\u884c\u76ee\u4ed8\u8fd1\u3092\u4ee5\u4e0b\u306e\u901a\u308a\u5909\u66f4\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#public $CharSet = 'iso-8859-1'; \u5143\u306f\u3053\u3061\u3089 \r\npublic $CharSet = 'UTF-8'; \/\/\u3053\u308c\u306b\u66f8\u304d\u63db\u3048<\/pre>\n<p>\u5c1a\u3001\u672c\u6587\u306e\u8a18\u8ff0\u306f\u3001<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$mailer-&gt;Body = '\u3042\u3044\u3046\u3048\u304a';<\/pre>\n<p>\u3067\u7279\u306b\u51e6\u7406\u3068\u304b\u305b\u305a\u306b\u3044\u3051\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30e1\u30fc\u30eb\u30b5\u30fc\u30d0\u30fc\u304c\u7acb\u3066\u3089\u308c\u306a\u304b\u3063\u305f\u308a\u3001\u7121\u6599\u30b5\u30fc\u30d0\u30fc\u306e\u305f\u3081\u4f7f\u3048\u306a\u304b\u3063\u305f\u308a\u3068\u3044\u3063\u305f\u5834\u5408 ... <\/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-1830","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\/1830","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=1830"}],"version-history":[{"count":0,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/1830\/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=1830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=1830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=1830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}