ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
| この記事の要点 |
|---|
|
エラーの状況
Symfony\Component\Mailer\Exception\TransportException:
Failed to authenticate on SMTP server with username "myuser" using the following authenticators: "LOGIN", "PLAIN", "XOAUTH2".
# または Laravel 5 系
Swift_TransportException:
Failed to authenticate on SMTP server with username "myuser" using 3 possible authenticators
# Gmail 特有
535-5.7.8 Username and Password not accepted.
主要 SMTP プロバイダの設定
| サービス | ホスト | ポート | 暗号化 | 認証 |
|---|---|---|---|---|
| Gmail | smtp.gmail.com | 587 | STARTTLS | アプリパスワード |
| Gmail (SSL) | smtp.gmail.com | 465 | SSL | アプリパスワード |
| Yahoo | smtp.mail.yahoo.com | 587/465 | STARTTLS/SSL | アプリパスワード |
| Outlook / Office 365 | smtp.office365.com | 587 | STARTTLS | 通常 PW or アプリパスワード |
| SendGrid | smtp.sendgrid.net | 587 | STARTTLS | API key |
| Mailgun | smtp.mailgun.org | 587 | STARTTLS | API key |
| Amazon SES | email-smtp.region.amazonaws.com | 587 | STARTTLS | SMTP 認証情報 |
| Postmark | smtp.postmarkapp.com | 587 | STARTTLS | API token |
Gmail でアプリパスワード取得
- Google アカウント (myaccount.google.com)
- セキュリティ → 2 段階認証プロセス を有効化(必須)
- 同じセキュリティ画面 → アプリパスワード
- 「メール」+ デバイス名(例: "My Laravel App")
- 16 文字のパスワードが生成される → コピー
- このパスワードを SMTP 設定で使用
Laravel での設定
# .env
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myuser@gmail.com
MAIL_PASSWORD=xxxx-xxxx-xxxx-xxxx # アプリパスワード
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=myuser@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
# キャッシュクリア (重要)
$ php artisan config:clear
$ php artisan cache:clear
# テスト送信
$ php artisan tinker
>>> Mail::raw("テスト", function ($m) { $m->to("test@example.com")->subject("テスト"); });
各プロバイダの SMTP 設定
SendGrid (推奨、無料枠 100 通/日)
MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey # ← 固定値 (実際の文字列 "apikey")
MAIL_PASSWORD=SG.xxxxx... # API key
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@yourdomain.com
# API キー取得: SendGrid → Settings → API Keys → Create
Mailgun
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster@mg.yourdomain.com
MAIL_PASSWORD=xxx # SMTP credentials
MAIL_ENCRYPTION=tls
Amazon SES
# SMTP 認証情報生成: AWS Console → SES → SMTP Settings
MAIL_MAILER=smtp
MAIL_HOST=email-smtp.us-east-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=AKIAxxx... # SMTP username (not IAM access key)
MAIL_PASSWORD=xxx # SMTP password (not IAM secret)
MAIL_ENCRYPTION=tls
Spring Boot での設定
# application.properties
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=myuser@gmail.com
spring.mail.password=xxxx-xxxx-xxxx-xxxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
SMTP 接続テスト
# telnet で接続テスト
$ telnet smtp.gmail.com 587
Trying 142.250.4.108...
Connected to smtp.gmail.com.
EHLO test
250-smtp.gmail.com at your service
250-PIPELINING
250-STARTTLS
QUIT
# openssl で SSL 接続
$ openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf
# Python でテスト
python3 -c "
import smtplib, ssl
context = ssl.create_default_context()
with smtplib.SMTP('smtp.gmail.com', 587) as s:
s.starttls(context=context)
s.login('user@gmail.com', 'app-password')
print('OK')
"
原因別の対処
① ユーザ名 / パスワード間違い
.envの値をコピペし直す- パスワードに特殊文字 ($ 等) が含まれる場合は引用符でくくる
- config:clear で反映
② 2 段階認証で通常パスワード不可
- Gmail / Yahoo: アプリパスワードを生成して使用
- Outlook: 通常パスワードでも可能なケースもあるが、アプリパスワード推奨
③ ポート / 暗号化ミスマッチ
- 587 → STARTTLS(推奨)
- 465 → SSL
- 25 → 暗号化なし(通常はブロック)
④ Less Secure Apps を許可(古い設定、非推奨)
Gmail はかつて「安全性の低いアプリ」を許可することで通常パスワード使えたが、2022 年に廃止。アプリパスワード一択。
⑤ ファイアウォール / プロバイダ制限
# 一部 ISP がポート 25 をブロック (スパム対策)
# 対策: 587 を使う
# 企業ネットワークで 587 もブロックされている場合
# - プロキシ経由
# - VPN
# - 別のサービス (REST API 経由のメール送信)
本番運用ベストプラクティス
- 専用メール配信サービス: SendGrid / Mailgun / SES / Postmark
- SPF / DKIM / DMARC 設定: 迷惑メール扱い回避
- 送信元アドレス: 認証済みドメインのみ
- レート制限: 1 時間あたりの送信数を制限
- キュー化: Laravel Queue / Spring @Async でバッチ送信
- バウンス処理: 配信失敗を検知して対応
関連記事
ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
子ページ
子ページはありません
同階層のページ
- SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost'
- Add [~] to fillable property to allow mass assignment on [App\~].
- PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in ~
- Changing columns for table "~" requires Doctrine DBAL; install "doctrine/dbal"
- MethodNotAllowedHttpException No message
- Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found
- production.ERROR: No application encryption key has been specified.
- Dotenv values containing spaces must be surrounded by quotes.
- Laravel \ Socialite \ Two \ InvalidStateException
- The page has expired due to inactivity. Please refresh and try again.
- Failed to clone https://github.com/symfony/thanks.git via https, ssh protocol
- Illegal offset type
- Cannot access protected property Illuminate\Http\Request::$...
- Emitted value instead of an instance of Error
- 画像保存時にInternal Server Error
- Failed to authenticate on SMTP server with username ...
- PostTooLargeException
- Database hosts array is empty.
- Invalid request (Unsupported SSL request)
- does not comply with psr-4 autoloading standard. Skipping.
- MySQLのSTR_TO_DATE関数を使用するとnullが返却される問題
人気ページ
- 1 Eclipseで「サーバーに追加または除去できるリソースがありません。」の原因と対処法
- 2 tomcat の起動 / 停止ログと catalina.log・catalina.out の違い
- 3 JavaScript base URL 取得方法|window.location.origin と SSR/Node.js 対応
- 4 YouTube Data API v3 エラー一覧|403/400/404 の主要原因と切り分け
- 5 Spring Frameworkのアノテーション一覧
- 6 Laravel エラー一覧|500/Blade/DB 接続/ルーティングの代表エラー
- 7 3Dグラフィックスとは|モデリング/レンダリング/主要ソフトウェア (Blender / Maya)
- 8 【Spring】@Valueアノテーションとは
- 9 CATALINA_HOME の確認方法 (Linux / Mac)
- 10 【Spring】@Autowiredアノテーションとは
最近更新/作成されたページ
- Laravel キャッシュクリア完全ガイド(cache:clear / config:clear / 2026-05-18 07:42:07
- プロジェクトの作成と削除 2026-05-18 07:42:07
- インストール直後にNetbeansが反応しない 2026-05-18 07:42:07
- 動画やチャンネルの検索 2026-05-18 07:42:07
- APIキー取得方法 2026-05-18 07:42:07
- チャンネル情報の取得 2026-05-18 07:42:07
- API 入門 — Web API(REST / GraphQL / gRPC / 2026-05-18 07:42:07
- インストール(eclipseプラグイン) 2026-05-18 07:42:07
- Laravel「Dotenv values containing spaces must be surrounded 2026-05-18 07:42:07
- エラー一覧 2026-05-18 07:42:07
- curl: (51) SSL: certificate subject name '~' does not match 2026-05-18 07:42:07
- インストール方法(Windows版) 2026-05-18 07:42:07
- JSONから配列に変換 2026-05-18 07:42:07
- 処理を一定時間待つ 2026-05-18 07:42:07
- A non well formed numeric value encountered 2026-05-18 07:42:07
コメントを削除してもよろしいでしょうか?