{"id":1221,"date":"2024-08-05T12:13:11","date_gmt":"2024-08-05T03:13:11","guid":{"rendered":"https:\/\/shinke1987.net\/?p=1221"},"modified":"2024-08-05T12:13:12","modified_gmt":"2024-08-05T03:13:12","slug":"phpmailer%e3%81%a7%e3%81%ae%e3%83%a1%e3%83%bc%e3%83%ab%e9%80%81%e4%bf%a1%e3%81%ae%e4%be%8b","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=1221","title":{"rendered":"PHPMailer\u3067\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u4f8b"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u524d\u63d0<\/h2>\n\n\n\n<p>PHPMailer \u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>PHP\uff1av8.3.7<br>PHPMailer\uff1av6.9.1<\/p>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">PHPMailer\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ mkdir MailTest &amp;&amp; cd MailTest\n$ composer require phpmailer\/phpmailer\n<\/pre><\/div>\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">mail.php \u306e\u5185\u5bb9<\/h2>\n\n\n\n<p>MailTest\u30d5\u30a9\u30eb\u30c0\u306b\u4e0b\u8a18\u5185\u5bb9\u306email.php \u3092\u8a2d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\nrequire_once &#039;.\/vendor\/autoload.php&#039;;\n\nuse PHPMailer\\PHPMailer\\PHPMailer;\nuse PHPMailer\\PHPMailer\\SMTP;\nuse PHPMailer\\PHPMailer\\Exception;\n\n$mail = new PHPMailer(true);\n\ntry {\n    $mail-&gt;SMTPDebug = SMTP::DEBUG_SERVER;\n    $mail-&gt;isSMTP();\n    $mail-&gt;Host = &#039;SMTP\u30b5\u30fc\u30d0\u306e\u30a2\u30c9\u30ec\u30b9&#039;;\n    $mail-&gt;SMTPAuth = true;\n    $mail-&gt;Username = &#039;SMTP\u30b5\u30fc\u30d0\u3078\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u6642\u306e\u30e6\u30fc\u30b6\u540d&#039;;\n    $mail-&gt;Password = &#039;SMTP\u30b5\u30fc\u30d0\u3078\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u6642\u306e\u30d1\u30b9\u30ef\u30fc\u30c9&#039;;\n    $mail-&gt;SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;\n    $mail-&gt;Port = 465;\n    $mail-&gt;CharSet = PHPMailer::CHARSET_UTF8;\n\n    $mail-&gt;setFrom(&#039;\u9001\u4fe1\u5143\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9&#039;, &#039;\u9001\u4fe1\u5143\u306e\u540d\u524d&#039;);\n    $mail-&gt;addAddress(&#039;\u9001\u4fe1\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9&#039;);\n    $mail-&gt;addReplyTo(&#039;\u8fd4\u4fe1\u5148\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff08\u5927\u62b5\u9001\u4fe1\u5143\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3068\u540c\u4e00\u3067\u826f\u3044\uff09&#039;);\n\n    $mail-&gt;isHTML(false);\n    $mail-&gt;Subject = &#039;mail.php\u306e\u30c6\u30b9\u30c8\uff08Subject\uff09&#039;;\n    $mail-&gt;Body = &#039;mail.php\u306e\u30c6\u30b9\u30c8\uff08Body\uff09&#039;;\n\n    $result = $mail-&gt;send();\n\n    printf(&quot;\\$result = {$result}\\n&quot;);\n} catch (Exception $e) {\n    echo $mail-&gt;ErrorInfo;\n}\n<\/pre><\/div>\n\n\n<h2 id=\"toc3\" class=\"wp-block-heading\">\u7d50\u679c\u78ba\u8a8d<\/h2>\n\n\n\n<p>\u30e1\u30fc\u30e9\u30fc\u3067\u5c4a\u3044\u305f\u30e1\u30fc\u30eb\u306e\u65e5\u672c\u8a9e\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308c\u3070\u826f\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u63d0 PHPMailer \u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5229\u7528\u3057\u307e\u3059\u3002 PHP\uff1av8.3.7PHPMailer\uff1av6.9.1 PHPMailer\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb \u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002 mail.php \u306e\u5185\u5bb9 MailTest\u30d5\u30a9\u30eb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[81,115],"class_list":["post-1221","post","type-post","status-publish","format-standard","hentry","category-php","tag-php","tag-phpmailer"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1221"}],"version-history":[{"count":4,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1221\/revisions"}],"predecessor-version":[{"id":1225,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1221\/revisions\/1225"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}