LightFile NextLightFile Next

SMTP Email通知

SMTPサーバー経由でメール通知を送信

ユーザーが指定するSMTPサーバー経由で継続不可能なエラー(Fatal Error)発生時にメールを送信します。

基本的な使い方

コマンドライン:

lightfile-batch local /path/to/images \
  --notify-smtp-to admin@example.com \
  --notify-smtp-from lightfile@example.com \
  --notify-smtp-host smtp.example.com \
  --notify-smtp-port 587 \
  --notify-smtp-user smtp_user \
  --notify-smtp-password smtp_password \
  --notify-smtp-use-tls=true

注意: --notify-smtp-use-tls を指定しない場合はTLSが無効のままになります。

YAML設定ファイル:

notify:
  smtp:
    to: admin@example.com
    from: lightfile@example.com
    host: smtp.example.com
    port: 587
    user: smtp_user
    password: smtp_password
    useTLS: true
local:
  dir: /path/to/images

メールの通知例

エラー発生時には、以下のような内容のメールが送信されます。実際にはマークダウン形式で記述された内容がHTMLメールとして成形されて届きます。

件名:

[server01.example.com] ⚠️ lightfile-batch 重大エラー通知

本文:

バッチ処理中に継続が困難なエラーが発生したため、プログラムの実行を中断しました。

## エラー内容

ライセンス検証に失敗しました

## 環境情報

* **プロジェクト名:** my-project
* **ホスト名:** server01.example.com
* **ファイルシステム:** local:///path/to/images
* **セッションディレクトリ:** /home/user/.lightfile-next/batch/my-project/sessions/20250127-103000
* **発生時刻:** 2025-01-27 10:30:00 JST

詳細はセッションディレクトリとログをご確認ください。

主要なSMTPサーバー設定例

Gmail

コマンドライン:

lightfile-batch local /path/to/images \
  --notify-smtp-to admin@example.com \
  --notify-smtp-from your-email@gmail.com \
  --notify-smtp-host smtp.gmail.com \
  --notify-smtp-port 587 \
  --notify-smtp-user your-email@gmail.com \
  --notify-smtp-password your-app-password \
  --notify-smtp-use-tls

YAML設定ファイル:

notify:
  smtp:
    to: admin@example.com
    from: your-email@gmail.com
    host: smtp.gmail.com
    port: 587
    user: your-email@gmail.com
    password: your-app-password
    useTLS: true
local:
  dir: /path/to/images

注意: Gmailではアプリパスワードの使用を推奨します。

SendGrid

コマンドライン:

lightfile-batch local /path/to/images \
  --notify-smtp-to admin@example.com \
  --notify-smtp-from verified@example.com \
  --notify-smtp-host smtp.sendgrid.net \
  --notify-smtp-port 587 \
  --notify-smtp-user apikey \
  --notify-smtp-password your-sendgrid-api-key \
  --notify-smtp-use-tls

YAML設定ファイル:

notify:
  smtp:
    to: admin@example.com
    from: verified@example.com
    host: smtp.sendgrid.net
    port: 587
    user: apikey
    password: your-sendgrid-api-key
    useTLS: true
local:
  dir: /path/to/images