Implementing the test Management system logic one mail sending configuration via Sping3 +hibernate4+strutsmvc

Source: Internet
Author: User
Tags one mail

Message entity class

 Public classMailImplementsSerializable { Public Static FinalString encodeing = "UTF-8"; PrivateString host;//Server Address    Private intPort//Port Settings    PrivateString Sender;//Sender's Mailbox    PrivateString receiver;//Recipient's Mailbox    PrivateString name;//Sender Nickname    PrivateString username;//Account Number    PrivateString password;//Password    PrivateString subject;//Theme    PrivateString message;//information (HTML supported)get () and set ()}

Mail Action Class

 Public BooleansendMail (mail mail) {//instantiate an email object to sendHtmlemail email =NewHtmlemail (); Try {              //the name of the SMTP sending server (e.g. QQ: "smtp.qq.com")Email.sethostname (Mail.gethost ()); //setting of the character encoding setEmail.setcharset (mail.encodeing); //Set PortEmail.setsmtpport (Mail.getport ()); //Recipient's Mailboxemail.addto (Mail.getreceiver ()); //Sender's MailboxEmail.setfrom (Mail.getsender (), Mail.getname ()); //If authentication is required//Set up authentication: User name-password. Is the sender's login name and password on the mail serveremail.setauthentication (Mail.getusername (), Mail.getpassword ()); //subject of the message to be sentEmail.setsubject (Mail.getsubject ()); //information to be sent, due to the use of htmlemail, the content of the message allows inserting HTML code blocksemail.setmsg (Mail.getmessage ()); //SendEmail.send (); return true; } Catch(emailexception e) {e.printstacktrace (); return false; }      }          

Implementing the test Management system logic one mail sending configuration via Sping3 +hibernate4+strutsmvc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.