Laravel From Scratch part. 7
Section 10 Mail
Send Raw Mail
Tailwindcssを使うみたいです。
初めてでもわかるTailwindcss入門(1) | アールエフェクト
<!DOCTYPE html> <html class="h-full"> <head> <meta http-equiv="Content-type" content="text/html; charset=UTF-8"> <title>Mail Lesson</title> <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"> </head> <body class="bg-gray-100 flex items-center justify-center h-full"> <form method="POST" action="/contact" class="bg-white p-6 rounded shadow-md" style="width: 300px"> @csrf <div class="mb-5"> <label for="email" class="block text-xs uppercase font-semibold mb-1"> Email Adress </label> <input type="text" id="email" name="email" class="border px-2 py-1 text-sm w-full"> </div> <button type="submit" class="bg-blue-500 py-2 text-white rounded-full text-sm w-full"> Email Me </button> </form> </body> </html>
入力されたメールアドレスが正しい形式かどうかの検証を行います。
メールを送信するために、.envファイルを
MAIL_DRIVER=log MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}"
とします。送信した内容は、storage/logsのファイルにあります。
Simulate an Inbox using Mailtrap
メール機能の開発のためにMailtrapを使います。
Mailtrap.io — Fake smtp testing server. Dummy smtp email testing
実際にMailtrapにメールが送信されたことを確認します。
Send HTML Emails Using Mailable Classes
HTML形式のメールを送ります。
Send Email Using Markdown Templates
Marldonw形式のメールを送ります。
Notifications Versus Mailables
Laravel Notification をやさしく解説する - Qiita
感想
メールの機能は使うことあまりなさそうです。