{"id":3796,"date":"2024-01-02T14:45:20","date_gmt":"2024-01-02T05:45:20","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=3796"},"modified":"2024-01-02T15:08:05","modified_gmt":"2024-01-02T06:08:05","slug":"post-3796","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/3796","title":{"rendered":"CodeIgniter4\u3067\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u65b9\u6cd5(\u30c6\u30ad\u30b9\u30c8\u30fbHTML\u30e1\u30fc\u30eb)"},"content":{"rendered":"<p>CodeIgniter4.4.4\u3067\u30c6\u30ad\u30b9\u30c8\u30e1\u30fc\u30eb\u53ca\u3073HTML\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u305f\u3044\u3002\u3064\u3044\u3067\u306b\u30d5\u30a1\u30a4\u30eb\u6dfb\u4ed8\u3001CC\u30fbBCC\u6a5f\u80fd\u3082\u3042\u308c\u3070\u672c\u756a\u6848\u4ef6\u3067\u3082\u4f7f\u3048\u305d\u3046\u3002\u4ee5\u4e0b\u306b\u5b9f\u88c5\u65b9\u6cd5\u3092\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/h2>\n<p><a href=\"https:\/\/codeigniter.com\/user_guide\/libraries\/email.html\" target=\"_blank\" rel=\"noopener\">https:\/\/codeigniter.com\/user_guide\/libraries\/email.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<h3>\u30c6\u30ad\u30b9\u30c8\u30e1\u30fc\u30eb<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$email = \\Config\\Services::email();\r\n$email-&gt;setFrom('from@test.com', '\u30c6\u30b9\u30c8\u9001\u4fe1\u8005\u540d');\r\n$email-&gt;setTo('to@test.com');\r\n$email-&gt;setSubject('\u30c6\u30b9\u30c8\u30bf\u30a4\u30c8\u30eb');\r\n$email-&gt;setMessage('\u30c6\u30b9\u30c8\u672c\u6587');\r\n$email-&gt;send();<\/pre>\n<h3>\u30c6\u30ad\u30b9\u30c8\u30e1\u30fc\u30eb(\u30d5\u30a1\u30a4\u30eb\u6dfb\u4ed8\u3001CC\u30fbBCC\u6a5f\u80fd\u4ed8\u304d)<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$email = \\Config\\Services::email();\r\n$email-&gt;setFrom('from@test.com', '\u30c6\u30b9\u30c8\u9001\u4fe1\u8005\u540d');\r\n$email-&gt;setTo('to@test.com');\r\n$email-&gt;setCC('cc@test.com');\r\n$email-&gt;setBCC('bcc@test.com');\r\n$email-&gt;setSubject('\u30c6\u30b9\u30c8\u30bf\u30a4\u30c8\u30eb');\r\n$email-&gt;setMessage('\u30c6\u30b9\u30c8\u672c\u6587');\r\n$email-&gt;attach('\/var\/www\/html\/test.jpg');\r\n$email-&gt;send();<\/pre>\n<h3>HTML\u30e1\u30fc\u30eb<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$email = \\Config\\Services::email();\r\n\r\n\/\/\u30e1\u30fc\u30eb\u30bf\u30a4\u30d7\u3092HTML\u306b\u5909\u66f4\r\n$mail_config['mailType'] = 'html';\r\n$email-&gt;initialize($mail_config);\r\n\r\n$email-&gt;setFrom('from@test.com', '\u30c6\u30b9\u30c8\u9001\u4fe1\u8005\u540d');\r\n$email-&gt;setTo('to@test.com');\r\n$email-&gt;setSubject('\u30c6\u30b9\u30c8\u30bf\u30a4\u30c8\u30eb');\r\n$body = '&lt;html lang=\"ja\"&gt;\r\n&lt;head&gt;\r\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\r\n&lt;title&gt;HTMLmail&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;HTML mail test&lt;\/h1&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n';\r\n$email-&gt;setMessage($body);\r\n$email-&gt;send();<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u30a8\u30e9\u30fc\u5224\u5b9a<\/h2>\n<p><a href=\"https:\/\/codeigniter.com\/user_guide\/libraries\/email.html#CodeIgniter\\Email\\Email::send\" target=\"_blank\" rel=\"noopener\">\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306b\u3088\u308b\u3068send()\u306e\u623b\u308a\u5024\u3067\u5224\u5b9a\u3067\u304d\u308b<\/a>\u6a21\u69d8\u3002\u305d\u306e\u305f\u3081\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5f62\u3067\u5206\u5c90\u51e6\u7406\u3055\u305b\u308b\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">if( $email-&gt;send() ){\r\n    \/\/\u9001\u4fe1\u6210\u529f\u6642\u306e\u51e6\u7406\r\n}else{\r\n    \/\/\u9001\u4fe1\u5931\u6557\u6642\u306e\u51e6\u7406\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u6240\u611f<\/h2>\n<p>\u30e1\u30fc\u30eb\u95a2\u9023\u306f\u7279\u306b\u554f\u984c\u7121\u3055\u305d\u3046\u306a\u306e\u3067\u30d5\u30a9\u30fc\u30e0\u3068\u7d44\u307f\u5408\u308f\u305b\u308c\u3070\u304a\u554f\u3044\u5408\u308f\u305b\u30da\u30fc\u30b8\u3068\u304b\u4f5c\u308c\u305d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CodeIgniter4.4.4\u3067\u30c6\u30ad\u30b9\u30c8\u30e1\u30fc\u30eb\u53ca\u3073HTML\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u305f\u3044\u3002 ... <\/p>\n","protected":false},"author":1,"featured_media":2517,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,80],"tags":[],"class_list":["post-3796","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-codeigniter"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3796","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=3796"}],"version-history":[{"count":0,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3796\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/2517"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=3796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=3796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=3796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}