java achieve email messages sent most simple and elegant way (for example 163)

How to use the IMAP service?

First, some basics of e-mail sent, if you already know can be skipped.

Directly to the Email messages sent part of the implementation.

IMAP is a what?

IMAP, namely Internet Message Access Protocol (Internet Message Access Protocol), you can get information, download e-mail messages from the mail server, etc. Through this agreement.

IMAP and POP similar, is a mail acquisition agreement.

IMAP and POP What is the difference?

POP email allows the client to download e-mail server, but you are operating e-mail client (such as: mobile e-mail, Mark Read, etc.), this is not going back to the server, such as: your end customers via e-mail charged QQ mailbox 3 message and moved to another folder, these actions will not move back to the server, that is, those messages on the QQ-mail server at the same time is not being moved.

But is different IMAP e-mail client operations will be fed back to the server, your mail operations carried out (such as: mobile e-mail, Mark Read, etc.), messages on the server will do the appropriate action.

That is, IMAP is a "two-way" in.

Meanwhile, IMAP can download only the subject of the message only when you really need, you will download all the contents of the message.

How to use the IMAP service?

Using IMAP is very simple, first of all, you need to enable IMAP feature QQ mailbox, and then configure the client, you can use.

Open SMTP service

QQ-mail

[Settings] - [Account] - [POP3 / IMAP / SMTP / Exchange / CardDAV / CalDAV service]

Lowermost open

  • POP3 / SMTP service

  • IMAP / SMTP services

163 E-mail

image

Netease is relatively simple, direct authorization code [open]

Email

Email is send a message based on the realization of java toolkit, keep it simple and elegant.

Writing reason

Read a variety of email tools did not imagine the feeling of convenience.

On their own to achieve a follow-up will continue to add new features.

characteristic

  • Fluent stream syntax

  • Send support 163 mailboxes

  • Support sending to multiple recipients, more (secret) CC's

Quick Start

Environmental requirements

jdk7 +

maven 3.x+

Introduced

<plugin>
    <groupId>com.github.houbb</groupId>
    <artifactId>email</artifactId>
    <version>0.0.2</version>
</plugin>

send email

Here NetEase mailbox passwords for the corresponding authorization code.

EmailBs.auth("[email protected]", "xxx")
        .content("自定义内容")
        .sendTo("[email protected]");

Here you will by [email protected]sent to the [email protected]e-mail.

Mail header default is no title, content for your custom content.

You can specify the configuration more feature-rich.

Method List

method Explanation
auth(username, password) username for the mailbox name, password is the corresponding password
content(subject, content) subject to the message header, content for the message content
content(content) The default subject is "Untitled", content for the message content
sendTo(toArray) toArray for the recipient list
cc(ccArray) ccArray for the Cc list
bcc(bccArray) bccArray secret Cc list

Examples of use

You can specify multiple recipients and Cc.

Sample code is as follows:

EmailBs.auth("[email protected]", "xxx")
       .content("自定义主题", "自定义内容")
       .cc("抄送者[email protected]", "抄送者[email protected]")
       .bcc("秘密抄送者[email protected]", "秘密抄送者[email protected]")
       .sendTo("收件人[email protected]", "收件人[email protected]");

Follow-up properties

  • Support for common mail

  • Support mail template

Further Reading

More real-time information, cutting-edge technology, life interesting. All in public horse Xiao westerly] [No.
Here Insert Picture Description

Reference material

java realize the mailbox to send mail function

java foundation for message sent (with qq and Netease, for example)

Resolve your mailbox inbox achieve javamail

Guess you like

Origin blog.51cto.com/9250070/2464776