Http://www.javaeye.com/topic/49031
In the past few days, a project was designed to use a large number of email sending APIs, So I sorted out the scatteredCodeAnd organize it into a class. We hope to use it for comrades who need it.
Define a mail configuration file to facilitate configuration modification,ProgramYou only need to read this configuration file, so that you do not need to modify it later.Source code
Java code
-
- /**
-
- * Provide the email address.
-
- */
-
- Public StaticString host_mail_name =Xxx@teesoo.com";
-
-
- /**
-
- * Provide the email address.
-
- */
-
- Public StaticString host_mail_password ="XXX";
-
-
-
- /**
-
- * Email sending protocol
-
- */
- Public StaticString SMTP ="Mail.teesoo.com";
-
-
-
- /**
-
- * Email receiving protocol
-
- */
-
- Public StaticString POP3 ="Mail.teesoo.com";
Email sending API
Java code
- Public Static VoidSend (string to, string subject, string body)ThrowsException {
-
- Mailer mail =NewMailer (manageconfig. SMTP );
-
- Mail. setnamepass (manageconfig. host_mail_name, manageconfig. host_mail_name );
-
- Mail. setfrom (manageconfig. host_mail_name );
-
- Mail. setsubject (subject );
- Mail. setbody (body,False);
-
- Mail. setto ();
-
- Mail. setneedauth (True);
-
- Mail. sendout ();
-
- }
I wrote a lot of food, but I sent it.
Src.rar |
Description: |
|
Download |
File Name: |
Src.rar |
File Size: |
3 KB |
Downloaded: |
File downloaded or viewed 197 times |