SMTP क्लाइंट गतिविधि लॉगिंग सक्षम करें
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)