バウンスアドレスとは?
バックパスまたは封筒の送信者とも呼ばれるバウンスアドレスは、メールが配信できない場合、非配達レポート(NDR)を受け取るメールアドレスです。 このアドレスは、受信者に表示される「From」アドレスから分離され、自動配信通知のためにのみ使用されます。
バウンスアドレスの仕組み
メール送信には2つのアドレスを使用します。
Header From(受取人に可)From: John Doe <john@example.com>
**(SMTPレベル、バウンスに使用されます):
MAIL FROM: <bounces@example.com>
配達が失敗すると、受信サーバーは、ヘッダ From アドレスではなく、封筒送信者にバウンスを送ります。
SMTP 会話例
Client: MAIL FROM: <bounces@example.com>
Server: 250 OK
Client: RCPT TO: <invalid@recipient.com>
Server: 550 No such user here
Client: QUIT
# Later, server sends bounce to bounces@example.com
メールバウンスの種類
##ハードバウンス
永久的な配達失敗:
- ユーザーは存在しません: 550 そのようなユーザ
- ドメインが存在しません: 550 ドメインが見つかりませんでした
- ポリシーによって拒否:ブロックされた550スパム
##ソフトバウンス
一時的な失敗:
ブロックバウンス
実行可能性の問題:
-
IP blacklisted: 554 サービスの利用できなくなった; Sender IP ブロック-
スパムとしてフィルタリングされたコンテンツ: 550 スパムスコアも高いバウンスアドレスの設定
メールヘッダーのリターンパスの設定
PHP (メール機能):$to = "recipient@example.com";
$subject = "Test Email";
$message = "Email body";
$headers = "From: sender@example.com\r\n";
$headers .= "Return-Path: bounces@example.com\r\n";
mail($to, $subject, $message, $headers, "-f bounces@example.com");
PHPMailer:
$mail = new PHPMailer();
$mail->From = "sender@example.com";
$mail->Sender = "bounces@example.com"; // Return path
$mail->addAddress("recipient@example.com");
$mail->Subject = "Test Email";
$mail->send();
ポストフィックス(SMTP):
# /etc/postfix/main.cf
sender_canonical_maps = hash:/etc/postfix/sender_canonical
# /etc/postfix/sender_canonical
@example.com bounces@example.com
# Apply changes
postmap /etc/postfix/sender_canonical
systemctl reload postfix
専用のバウンス処理サービス
ほとんどの電子メールサービスプロバイダはバウンス管理を提供します:
アマゾンSES:{
"Message": {
"Subject": "Test",
"From": "sender@example.com",
"ReturnPath": "bounces@example.com"
}
}
SendGrid**:
const msg = {
to: 'recipient@example.com',
from: 'sender@example.com',
replyTo: 'reply@example.com',
return_path: 'bounces@example.com',
subject: 'Test Email',
text: 'Email body'
};
バウンスアドレスナンシング条約
##サブドメインのアプローチ
bounces@example.com # General bounces
no-reply@example.com # No-reply emails
returns@example.com # Returns/receipts
##キャンペーン
キャンペーンごとのバウンスを追跡:
bounces-newsletter@example.com
bounces-campaign-123@example.com
bounces-transaction@example.com
##変数封筒リターンパス(VERP)
バウンスアドレスで受信者をエンコード:
Sending to: user@recipient.com
Return path: bounces+user=recipient.com@example.com
When bounce arrives at bounces+*, parse to identify failed recipient
バウンスメッセージの処理
自動バウンスパーシング
Pythonの例:import email
from email import policy
def parse_bounce(raw_email):
msg = email.message_from_string(raw_email, policy=policy.default)
# Extract bounce type
if "550" in msg.get_payload():
return "hard_bounce"
elif "452" in msg.get_payload():
return "soft_bounce"
# Extract failed recipient
for part in msg.walk():
if part.get_content_type() == "message/delivery-status":
# Parse delivery status
pass
return bounce_info
# Integrate with mailing list to remove hard bounces
Webhookベースのバウンス処理
現代ESPはwebhooksを提供します:
SendGrid Webhook:POST /bounce-webhook
{
"email": "recipient@example.com",
"event": "bounce",
"reason": "550 5.1.1 User unknown",
"type": "blocked",
"status": "5.0.0"
}
アクション: データベースを更新して、メールをバウンスとしてマークします。
SPFとBounceアドレス
SPFは、ヘッダではなく、封筒の送信者(バウンスアドレス)をチェックします。
Message:
From: newsletter@example.com (header)
Return-Path: bounces@mail-server.com (envelope)
SPF Check:
Queries: mail-server.com TXT record (not example.com)
Must include sending IP in mail-server.com's SPF
バウンスドメインSPF構成
bounces.example.com. IN TXT "v=spf1 include:_spf.sendgrid.net ~all"
あなたのバウンスサブドメインが、送信インフラに適したSPFレコードを持っていることを確認してください。
バウンスアドレスベストプラクティス
専用バウンスアドレスを使用する
最初のメールをバウンスに使用することはありません。
# Bad
Return-Path: info@example.com
# Good
Return-Path: bounces@example.com
モニター バウンス率
| バウンス率 | 評価評価 | アクション |
|---|---|---|
| < 2% | ヘルシー | モニタリングの継続 |
| 25%の | お問い合わせ | 監査メールリストの品質 |
| 5~10% | ポアー | 必要な即時のリストのクリーニング |
| ・10% | クリティカル | リスクの達成性 |
###Bounce処理の実装
堅い警備員の取り外しを自動化して下さい:
-- Mark emails with hard bounces
UPDATE mailing_list
SET status = 'bounced', bounce_count = bounce_count + 1
WHERE email IN (SELECT email FROM recent_hard_bounces);
-- Remove after 3 hard bounces
DELETE FROM mailing_list
WHERE bounce_count >= 3;
###別々の取引とマーケティングバウンス
transactional-bounces@example.com # Order confirmations, receipts
marketing-bounces@example.com # Newsletters, campaigns
各タイプごとに異なるバウンス率が期待されます。
バウンス処理自動化の設定
Cronジョブ例:#!/bin/bash
# Process bounces every hour
# Fetch bounces from IMAP
fetchmail -c /etc/fetchmailrc
# Parse and update database
/usr/local/bin/process-bounces.py
# Clean up processed bounces older than 30 days
find /var/mail/bounces -mtime +30 -delete
バックスキャッターとバウンスセキュリティ
バックスキャッターの問題
サーバがスパムを受信し、それをバウンスすると、偽造されたアドレスに送信されます。
1. Spammer sends email with forged From
2. Your server accepts it
3. Your server realizes it's spam/invalid
4. Your server bounces to forged From address
5. Innocent party receives bounce (backscatter)
ソリューション: SMTPの時間で注入して下さい、それから跳ね上がりません:
# Postfix: Reject unknown users at SMTP time
smtpd_recipient_restrictions = reject_unauth_destination
local_recipient_maps = hash:/etc/postfix/local_recipients
##Bounce フォアジェリ
攻撃者はバウンスメッセージを強制することができます:
- 有効なアドレスを収穫して下さい
- バウンスとして偽装したスパムを配信
- 偽のデリバリーレポートによるフィッシング資格情報
- MXサーバーから発信されたバウンスをチェックする
- バウンスの確認は、実際に送信したメールのことです
- 慎重に配達スタタスヘッダーをパース
一般的なバウンスシナリオ
シナリオ1:すべての電子メールのブロンシング
原因:SPF障害、IPブラックリスト、またはサーバーの評判 チェック:SPFレコード、送信者IPの評判、DMARCレポート##Scenario 2:Bounces 受信しない
原因: バウンスアドレスの誤設定や存在しない チェック: バウンスドメインのMXレコード、メールボックスが存在します##シナリオ3:高ソフトバウンス率
原因: 受信サーバーの過負荷、制限速度、大きなメッセージ チェック: レート、メッセージサイズ、受信サーバーエラーの送信##シナリオ4:バウンスループ
原因: バウンスアドレスは自動返信をトリガーし、別のバウンスをトリガーします。 チェック: バウンスアドレスで自動応答を無効にするバウンス処理のテスト
無効な受信者とテストメールを送信します:# Test bounce to invalid address
swaks --to invalid-user@test-domain.com \
--from bounces@example.com \
--server mx.test-domain.com
# Check if bounce arrives at bounces@example.com
バウンスドメインのSPFを検証:
dig bounces.example.com TXT
# Should show SPF record with authorized senders
適切なバウンスアドレス管理は、送信者の評判、リスト衛生、および提供性を維持するために不可欠です。