Java Send mail (i)

Source: Internet
Author: User

A: Preface

Always want to do the Java e-mail features, but has not been successful, special no language Ah, so there is time for me to finally succeed Ah, although the simplest, but still recorded it!

II: Content

The main requirement here is Spring-context-support.jar and Mail.jar, so you can use the frame to build it yourself.

Package Com.wh.graduate.controller;import Org.springframework.mail.simplemailmessage;import Org.springframework.mail.javamail.javamailsenderimpl;import org.springframework.stereotype.controller;@ Controllerpublic class Mailcontroller {public static void main (string[] args) {Javamailsenderimpl Senderimpl = new Javama Ilsenderimpl ();  Senderimpl.sethost ("smtp.qq.com");  Senderimpl.setport (+);     Senderimpl.setusername ("xx");      Senderimpl.setpassword ("xxx");           Mail message settings     simplemailmessage mailmessage = new Simplemailmessage ();      Mailmessage.setto ("[email protected]");      Mailmessage.setfrom ("[email protected]");      Mailmessage.setsubject ("First email Oh");      Mailmessage.settext ("Mail test out! ");      Send mail      senderimpl.send (mailmessage);}    }

This bug will be reported initially:

454 authentication failed, please open SMTP flag first!

Baidu after the settlement method:

To turn these services on!

Three: summary

Finally send their own success once, I am, the practice is to test the truth of the best standards!

Java Send mail (i)

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.