Use JavaMail to send mail in Java

Source: Internet
Author: User
Tags email account

1. e-Mail protocol

e-mail is transmitted over the network as well as Web pages that require compliance with specific protocols, and commonly used e-mail protocols include Smtp,pop3,imap.
The SMTP protocol is used only for the creation and sending of messages, and all of this is only related to the SMTP protocol. SMTP is the short name of Simple Mail Transfer Protocol, which is simply the message Transfer Protocol.

2. JavaMail

Java official also provides the Java class library which encapsulates the e-mail protocol, is javamail, but does not include in the standard JDK, needs us to go to Java or the Oracle official website to download.

:
Https://java.net/projects/javamail/pages/Home or http://www.oracle.com/technetwork/java/javamail/index.html

Third, the premise of sending mail
To send a message, you first need to have a mailbox account and password, and the email account must have the SMTP service turned on.
Take 163 mailbox As an example, after you log on to a mailbox in a browser Web page, you can usually open it in the Settings tab of the mailbox and note the SMTP server address of the mailbox:
    
Four. Create and send an email

Message creation steps:

Create a Mail object (mimemessage);
Set sender, recipient, optional Add multiple recipients, cc person, secret send person;
Set the subject (title) of the message;
Set the body of the message (content, attachments);
Set the sending time of the display;
Save to Local.

Use JavaMail to send mail in Java

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.