הפעלת רישום פעילות של לקוח SMTP

Contents
[ ]

Aspose.Email עבור Python דרך .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)