का उपयोग कर जावा में ईमेल भेजना मैं ईमेल भेजने के लिए अपाचे कॉमन्स ईमेल लाइब्रेरी का उपयोग कर रहा हूं, लेकिन मैं उन्हें जीमेल एसएमटीपी सर्वर के माध्यम से भेजने में सक्षम नहीं हूं।
कोई भी नमूना कोड प्रदान कर सकता है जो जीमेल एसएमटीपी सर्वर और अन्य के साथ काम करता है?अपाचे कॉमन्स ईमेल libs
String[] recipients = {"[email protected]"};
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setAuthentication("[email protected]", "mypasswd");
email.setDebug(true);
email.setSmtpPort(465);
for (int i = 0; i < recipients.length; i++)
{
email.addTo(recipients[i]);
}
email.setFrom("[email protected]", "Me");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();