SMTP クライアントのアクティビティ ロギングを有効化
Contents
[
Hide
]
.NET 経由の Python 用 Aspose.Email は、SMTP アクティビティのロギングを組み込みでサポートしています。この機能(一般にアクティビティ ロギングとして知られる)は、送信プロセス中のメール取引、イベント、エラーを体系的に追跡でき、デバッグ、監査、またはサーバー側アプリケーションにおける運用透明性の維持に特に有用です。
この SmtpClient このクラスは、アクティビティ ロギングを有効化および設定するための以下のプロパティを提供します:
-
log_file_name: ログファイルのフルパスと名前を指定します。 -
use_date_in_log_file_name: ログファイル名に現在の日付を付加するかどうかを決定します。日次ログの作成に便利です。
以下のコードサンプルは、プログラムコードで SMTP アクティビティ ロギングを有効にする方法を示しています:
import aspose.email as ae
# Initialize and configure the SMTP client
client = ae.clients.smtp.SmtpClient
client.host = "<HOST>"
client.username = "<USERNAME>"
client.password = "<PASSWORD>"
client.port = 587
client.security_options = ae.clients.SecurityOptions.SSL_EXPLICIT
# Set the log file name and enable/disable date in file name
client.log_file_name = "C:\Aspose.Email.Smtp.log"
# Set to True to append current date
client.use_date_in_log_file_name = False
# Prepare and send the email
eml = ae.MailMessage("from address", "to address", "this is a test subject", "this is a test body")
client.send(eml)