All Projects → biezhi → Oh My Email

biezhi / Oh My Email

📪 可能是最小的 Java 邮件发送库了,支持抄送、附件、模板等功能。

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Oh My Email

Astroid
A graphical threads-with-tags style, lightweight and fast, e-mail client for Notmuch
Stars: ✭ 476 (-22.22%)
Mutual labels:  email
Letter opener web
A web interface for browsing Ruby on Rails sent emails
Stars: ✭ 513 (-16.18%)
Mutual labels:  email
Exim
Exim Mail Transport Agent - source, testsuite and documentation
Stars: ✭ 545 (-10.95%)
Mutual labels:  email
Aerc
Asynchronous email client for your terminal
Stars: ✭ 483 (-21.08%)
Mutual labels:  email
Premailer.net
C# library that moves your stylesheets to inline style attributes, for maximum compatibility with E-mail clients.
Stars: ✭ 503 (-17.81%)
Mutual labels:  email
Responsive Html Email Signature
Template generator for (responsive) emails & email signatures ✨
Stars: ✭ 525 (-14.22%)
Mutual labels:  email
Sieve
Sieve Script Editor
Stars: ✭ 452 (-26.14%)
Mutual labels:  email
Teemo
A Domain Name & Email Address Collection Tool
Stars: ✭ 595 (-2.78%)
Mutual labels:  email
Thunderbird Conversations
An extension for Thunderbird that allows you to view threads as "real" conversations, including your own emails. This extension also adds a bunch of useful UI features in the conversation view.
Stars: ✭ 512 (-16.34%)
Mutual labels:  email
Core
Dovecot mail server
Stars: ✭ 540 (-11.76%)
Mutual labels:  email
Glass Isc Dhcp
Glass - ISC DHCP Server Interface
Stars: ✭ 486 (-20.59%)
Mutual labels:  email
Mfcmapi
MFCMAPI
Stars: ✭ 501 (-18.14%)
Mutual labels:  email
Deltachat Desktop
Email-based instant messaging for Desktop.
Stars: ✭ 526 (-14.05%)
Mutual labels:  email
Salmon
A Python Mail Server
Stars: ✭ 482 (-21.24%)
Mutual labels:  email
Alot
Terminal-based Mail User Agent
Stars: ✭ 572 (-6.54%)
Mutual labels:  email
Nylas Mail
💌 An extensible desktop mail app built on the modern web.
Stars: ✭ 473 (-22.71%)
Mutual labels:  email
Sendgrid Ruby
The Official Twilio SendGrid Led, Community Driven Ruby API Library
Stars: ✭ 520 (-15.03%)
Mutual labels:  email
Mailer
The Mailer component helps sending emails
Stars: ✭ 609 (-0.49%)
Mutual labels:  email
Holehe
holehe allows you to check if the mail is used on different sites like twitter, instagram and will retrieve information on sites with the forgotten password function.
Stars: ✭ 568 (-7.19%)
Mutual labels:  email
Socialscan
Python library and CLI for accurately querying username and email usage on online platforms
Stars: ✭ 538 (-12.09%)
Mutual labels:  email

oh-my-email

或许是最小的 Java 邮件发送类库了。

Build Status Codacy Badge codecov.io maven-central License Twitter URL

特性

  • 简洁的邮件发送API
  • 支持自定义发件人昵称
  • 支持扩展邮件Message
  • 支持抄送/HTML/附件
  • 支持异步发送
  • 支持邮件模板
  • 可能是代码量最小的库了,200多行 😂 非常好维护

使用

maven坐标

<dependency>
    <groupId>io.github.biezhi</groupId>
    <artifactId>oh-my-email</artifactId>
    <version>0.0.4</version>
</dependency>

举个栗子🌰

@Before
public void before() throws GeneralSecurityException {
    // 配置,一次即可
    OhMyEmail.config(SMTP_QQ(), "[email protected]", "[email protected]");
}

@Test
public void testSendText() throws MessagingException {
    OhMyEmail.subject("这是一封测试TEXT邮件")
            .from("小姐姐的邮箱")
            .to("[email protected]")
            .text("信件内容")
            .send();
}

@Test
public void testSendHtml() throws MessagingException {
    OhMyEmail.subject("这是一封测试HTML邮件")
            .from("小姐姐的邮箱")
            .to("[email protected]")
            .html("<h1 font=red>信件内容</h1>")
            .send();
}

@Test
public void testSendAttach() throws MessagingException {
    OhMyEmail.subject("这是一封测试附件邮件")
            .from("小姐姐的邮箱")
            .to("[email protected]")
            .html("<h1 font=red>信件内容</h1>")
            .attach(new File("/Users/biezhi/Downloads/hello.jpeg"), "测试图片.jpeg")
            .send();
}

@Test
public void testSendAttachURL() throws MessagingException {
    try {
        OhMyEmail.subject("这是一封测试网络资源作为附件的邮件")
                .from("小姐姐的邮箱")
                .to("[email protected]")
                .html("<h1 font=red>信件内容</h1>")
                .attachURL(new URL("https://avatars1.githubusercontent.com/u/2784452?s=40&v=4"), "测试图片.jpeg")
                .send();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}


@Test
public void testPebble() throws IOException, PebbleException, MessagingException {
    PebbleEngine engine = new PebbleEngine.Builder().build();
    PebbleTemplate compiledTemplate = engine.getTemplate("register.html");

    Map<String, Object> context = new HashMap<String, Object>();
    context.put("username", "biezhi");
    context.put("email", "[email protected]");

    Writer writer = new StringWriter();
    compiledTemplate.evaluate(writer, context);

    String output = writer.toString();
    System.out.println(output);

    OhMyEmail.subject("这是一封测试Pebble模板邮件")
            .from("小姐姐的邮箱")
            .to("[email protected]")
            .html(output)
            .send();
}

@Test
public void testJetx() throws IOException, PebbleException, MessagingException {
    JetEngine engine = JetEngine.create();
    JetTemplate template = engine.getTemplate("/register.jetx");

    Map<String, Object> context = new HashMap<String, Object>();
    context.put("username", "biezhi");
    context.put("email", "[email protected]");
    context.put("url", "<a href='http://biezhi.me'>https://biezhi.me/active/asdkjajdasjdkaweoi</a>");

    StringWriter writer = new StringWriter();
    template.render(context, writer);
    String output = writer.toString();
    System.out.println(output);

    OhMyEmail.subject("这是一封测试Jetx模板邮件")
            .from("小姐姐的邮箱")
            .to("[email protected]")
            .html(output)
            .send();
}

邮件模版

<div>
    <p>亲爱的<b>{{ username }}</b>, 欢迎加入 biezhi !</p>
    <p>当您收到这封信的时候,您已经可以正常登录了。</p>
    <p>请点击链接登录首页: <a href='http://www.baidu.com'>http://biezhi.me/xxxxx</a></p>
    <p>如果您的 email 程序不支持链接点击,请将上面的地址拷贝至您的浏览器(如IE)的地址栏进入。</p>
    <p>如果您还想申请管理员权限,可以联系管理员 {{ email }}</p>
    <p>我们对您产生的不便,深表歉意。</p>
    <p>希望您在 biezhi 系统度过快乐的时光!</p>
    <p></p>
    <p>-----------------------</p>
    <p></p>
    <p>(这是一封自动产生的email,请勿回复。)</p>
</div>

问题建议

  • 我的邮箱:biezhi.me#gmail.com
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].