SMTP 클라이언트 활동 로깅 활성화
Contents
[
Hide
]
Aspose.Email for Python via .NET은 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)