{"id":11797,"date":"2022-03-11T10:00:00","date_gmt":"2022-03-11T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11797"},"modified":"2022-03-10T19:06:19","modified_gmt":"2022-03-10T10:06:19","slug":"laravel-8%e3%81%ae%e3%83%a1%e3%83%bc%e3%83%ab%e9%80%81%e4%bf%a1%e3%81%ae%e4%be%8b%e3%81%a8%e3%80%81alwaysto%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e8%aa%a4%e9%80%81%e4%bf%a1%e3%82%92%e9%98%b2%e3%81%90","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11797","title":{"rendered":"Laravel 8\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u4f8b\u3068\u3001alwaysTo()\u3092\u4f7f\u3063\u3066\u8aa4\u9001\u4fe1\u3092\u9632\u3050\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u4eca\u56de\u306f\u3001Laravel 8\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u4f8b\u3068\u3001alwaysTo()\u3092\u4f7f\u3063\u3066\u8aa4\u9001\u4fe1\u3092\u9632\u3050\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Laravel 8\u306b\u306f\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u305f\u3081\u306email\u30af\u30e9\u30b9\u304c\u3042\u308a\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u305f\u3081\u306e\u30c9\u30e9\u30a4\u30d0\u30fc\u3092\u8907\u6570\u7528\u610f\u3057\u3001\u304a\u597d\u307f\u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002smtp\u3001Mailgun\u3001Postmark\u3001Amazon SES\u3001sendmail\u304c\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u3069\u306e\u30c9\u30e9\u30a4\u30d0\u3092\u4f7f\u7528\u3059\u308b\u304b\u306f\u3001env\u30d5\u30a1\u30a4\u30eb\u3067\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br>\u4eca\u56de\u306fsmtp\u30c9\u30e9\u30a4\u30d0\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4>.env\u3067SMTP\u3092\u8a2d\u5b9a\u3059\u308b<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>MAIL_MAILER=smtp\nMAIL_HOST=smtp.gmail.com\nMAIL_PORT=587\nMAIL_USERNAME=Add your user name here\nMAIL_PASSWORD=Add your password here\nMAIL_ENCRYPTION=tls\nMAIL_FROM_ADDRESS=Add your user name here<\/code><\/pre>\n\n\n\n<p>\u203b\u30e1\u30fc\u30eb\u3092\u4f7f\u3044\u5834\u5408\u3001google\u30a2\u30ab\u30a6\u30f3\u30c8\u306eless secure app access\u3067turn\u3092\u30aa\u30f3\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h4>\u5229\u7528\u53ef\u80fd\u306a\u30e1\u30fc\u30eb\u30af\u30e9\u30b9\u306e\u4f5c\u6210<\/h4>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001MyTestMail\u3068\u3044\u3046\u540d\u3067\u30e1\u30a4\u30e9\u30d6\u30eb\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan make:mail MyTestMail<\/code><\/pre>\n\n\n\n<p>MyTestMail\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    public $details;\n    public function __construct($details)\n    {\n        $this-&gt;details = $details;\n    }\n\n    public function build()\n    {\n        return $this-&gt;subject('Mail from AMI')\n                    -&gt;view('emails.myTestMail');\n    }<\/code><\/pre>\n\n\n\n<h3>\u30d6\u30ec\u30fc\u30c9\u30d3\u30e5\u30fc\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u30d6\u30ec\u30fc\u30c9\u30d3\u30e5\u30fc\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u9001\u4fe1\u3059\u308b\u30e1\u30fc\u30eb\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\u300cemails\u300d\u30d5\u30a9\u30eb\u30c0\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;\u30e1\u30fc\u30eb\u9001\u4fe1\u30c6\u30b9\u30c8&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;{{ $details&#091;'title'] }}&lt;\/h1&gt;\n    &lt;p&gt;{{ $details&#091;'body'] }}&lt;\/p&gt;\n   \n    &lt;p&gt;Thank you&lt;\/p&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>\u6700\u5f8c\u306b\u3001\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u305f\u3081\u306e &#8220;MyTestMail &#8220;\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nRoute::get('send-mail', function () {\n   \n    $details = &#091;\n        'title' =&gt; 'Mail from AMI',\n        'body' =&gt; 'This is for testing email using smtp'\n    ];\n   \n    \\Mail::to('name@gmail.com')-&gt;send(new \\App\\Mail\\MyTestMail($details));\n   \n    dd(\"Email is Sent.\");\n});<\/code><\/pre>\n\n\n\n<h3>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u7d50\u679c\u306f<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"940\" height=\"326\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/03\/Screen-Shot-2022-03-10-at-10.19.03.png\" alt=\"\" class=\"wp-image-11798\" \/><\/figure>\n\n\n\n<p>\u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u74b0\u5883\u304b\u3089\u5b9f\u969b\u306e\u304a\u5ba2\u69d8\u306b\u8aa4\u3063\u3066\u4f55\u5343\u901a\u3082\u306e\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u3066\u3057\u307e\u3046\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u6642\u3001\u3069\u3046\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u306e\u304b\u3092\u5171\u6709\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class AppServiceProvider extends ServiceProvider\n{\n    \/\/ Stuff omitted\n \n    public function boot()\n    {\n        f (! app()-&gt;environment('production')) {\n            Mail::alwaysTo('ex@example.org');\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3>alwaysTo\u3067\u4f55\u304c\u8d77\u304d\u3066\u3044\u308b\u306e\u304b\uff1f<\/h3>\n\n\n\n<p>alwaysTo() \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30e1\u30fc\u30eb\u30e1\u30c3\u30bb\u30fc\u30b8\u5185\u306e to, cc, bcc \u306b\u8ffd\u52a0\u3055\u308c\u305f\u3059\u3079\u3066\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u4e0a\u66f8\u304d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3053\u3067\u3001\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001Laravel\u306b\u3001\u672c\u756a\u74b0\u5883\u3067\u306a\u3044\u5834\u5408\u306e\u307f\u3001ex@example.org \u306b\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3059\u308b\u3088\u3046\u306b\u6307\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306f\u3053\u308c\u3067\u7d42\u308f\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<p>By Ami<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11797\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11797\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Laravel 8\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u4f8b\u3068\u3001alwaysTo()\u3092\u4f7f\u3063\u3066\u8aa4\u9001\u4fe1\u3092\u9632\u3050\u65b9\u6cd5\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11797\" data-text=\"Laravel 8\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u4f8b\u3068\u3001alwaysTo()\u3092\u4f7f\u3063\u3066\u8aa4\u9001\u4fe1\u3092\u9632\u3050\u65b9\u6cd5\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11797\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11797\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306f\u3001Laravel 8\u306e\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u4f8b\u3068\u3001alwaysTo()\u3092\u4f7f\u3063\u3066\u8aa4\u9001\u4fe1\u3092\u9632\u3050\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 Laravel 8\u306b\u306f\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u305f\u3081\u306email\u30af\u30e9\u30b9\u304c\u3042\u308a\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u305f\u3081\u306e\u30c9\u30e9\u30a4\u30d0\u30fc\u3092\u8907\u6570\u7528\u610f\u3057\u3001\u304a\u597d\u307f\u3067 [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11797"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=11797"}],"version-history":[{"count":4,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11797\/revisions"}],"predecessor-version":[{"id":11803,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11797\/revisions\/11803"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}