SMTP क्लाइंट गतिविधि लॉगिंग सक्षम करें

Contents
[ ]

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 the date in the file name
client.log_file_name = r"C:\Aspose.Email.Smtp.log"

# Set to True to append the current date
client.use_date_in_log_file_name = False

# Prepare and send the email
eml = ae.MailMessage("from@domain.com", "to@domain.com", "This is a test subject", "This is a test body")
client.send(eml)