{"id":17970039,"url":"https://github.com/hellokaton/oh-my-email","last_synced_at":"2025-05-15T04:03:41.956Z","repository":{"id":44470258,"uuid":"54269985","full_name":"hellokaton/oh-my-email","owner":"hellokaton","description":"📪 可能是最小的 Java 邮件发送库了，支持抄送、附件、模板等功能。","archived":false,"fork":false,"pushed_at":"2025-02-19T02:44:38.000Z","size":69,"stargazers_count":721,"open_issues_count":15,"forks_count":221,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-07T00:07:28.068Z","etag":null,"topics":["email","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellokaton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-19T14:26:43.000Z","updated_at":"2025-03-04T09:59:52.000Z","dependencies_parsed_at":"2022-09-13T15:00:29.264Z","dependency_job_id":null,"html_url":"https://github.com/hellokaton/oh-my-email","commit_stats":null,"previous_names":["junicorn/jmail","biezhi/oh-my-email"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellokaton%2Foh-my-email","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellokaton%2Foh-my-email/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellokaton%2Foh-my-email/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellokaton%2Foh-my-email/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellokaton","download_url":"https://codeload.github.com/hellokaton/oh-my-email/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819379,"owners_count":21166477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","java"],"created_at":"2024-10-29T15:01:39.205Z","updated_at":"2025-04-14T03:58:33.134Z","avatar_url":"https://github.com/hellokaton.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# oh-my-email\n\n或许是最小的 Java 邮件发送类库了。\n\n[![Build Status](https://img.shields.io/travis/biezhi/oh-my-email.svg?style=flat-square)](https://travis-ci.org/biezhi/oh-my-email)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2ef611f3fa044c8f8d8fc31cf0acd8a7)](https://www.codacy.com/app/biezhi/oh-my-email?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=biezhi/oh-my-email\u0026amp;utm_campaign=Badge_Grade)\n[![codecov.io](https://img.shields.io/codecov/c/github/biezhi/oh-my-email/master.svg?style=flat-square)](http://codecov.io/github/biezhi/oh-my-email?branch=master)\n[![maven-central](https://img.shields.io/maven-central/v/io.github.biezhi/oh-my-email.svg?style=flat-square)](http://search.maven.org/#search%7Cga%7C1%7Coh-my-email)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/biezhii.svg?style=social\u0026label=Follow%20Twitter)](https://twitter.com/biezhii)\n\n## 特性\n\n- 简洁的邮件发送API\n- 支持自定义发件人昵称\n- 支持扩展邮件Message\n- 支持抄送／HTML／附件\n- 支持异步发送\n- 支持邮件模板\n- 可能是代码量最小的库了，200多行 😂 非常好维护\n\n## 使用\n\n**maven坐标**\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.biezhi\u003c/groupId\u003e\n    \u003cartifactId\u003eoh-my-email\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 举个栗子🌰\n\n```java\n@Before\npublic void before() throws GeneralSecurityException {\n    // 配置，一次即可\n    OhMyEmail.config(SMTP_QQ(), \"xiaojiejie@qq.com\", \"your@password\");\n}\n\n@Test\npublic void testSendText() throws MessagingException {\n    OhMyEmail.subject(\"这是一封测试TEXT邮件\")\n            .from(\"小姐姐的邮箱\")\n            .to(\"xiaojiejie@gmail.com\")\n            .text(\"信件内容\")\n            .send();\n}\n\n@Test\npublic void testSendHtml() throws MessagingException {\n    OhMyEmail.subject(\"这是一封测试HTML邮件\")\n            .from(\"小姐姐的邮箱\")\n            .to(\"xiaojiejie@gmail.com\")\n            .html(\"\u003ch1 font=red\u003e信件内容\u003c/h1\u003e\")\n            .send();\n}\n\n@Test\npublic void testSendAttach() throws MessagingException {\n    OhMyEmail.subject(\"这是一封测试附件邮件\")\n            .from(\"小姐姐的邮箱\")\n            .to(\"xiaojiejie@gmail.com\")\n            .html(\"\u003ch1 font=red\u003e信件内容\u003c/h1\u003e\")\n            .attach(new File(\"/Users/biezhi/Downloads/hello.jpeg\"), \"测试图片.jpeg\")\n            .send();\n}\n\n@Test\npublic void testSendAttachURL() throws MessagingException {\n    try {\n        OhMyEmail.subject(\"这是一封测试网络资源作为附件的邮件\")\n                .from(\"小姐姐的邮箱\")\n                .to(\"xiaojiejie@gmail.com\")\n                .html(\"\u003ch1 font=red\u003e信件内容\u003c/h1\u003e\")\n                .attachURL(new URL(\"https://avatars1.githubusercontent.com/u/2784452?s=40\u0026v=4\"), \"测试图片.jpeg\")\n                .send();\n    } catch (MalformedURLException e) {\n        e.printStackTrace();\n    }\n}\n\n\n@Test\npublic void testPebble() throws IOException, PebbleException, MessagingException {\n    PebbleEngine engine = new PebbleEngine.Builder().build();\n    PebbleTemplate compiledTemplate = engine.getTemplate(\"register.html\");\n\n    Map\u003cString, Object\u003e context = new HashMap\u003cString, Object\u003e();\n    context.put(\"username\", \"biezhi\");\n    context.put(\"email\", \"admin@biezhi.me\");\n\n    Writer writer = new StringWriter();\n    compiledTemplate.evaluate(writer, context);\n\n    String output = writer.toString();\n    System.out.println(output);\n\n    OhMyEmail.subject(\"这是一封测试Pebble模板邮件\")\n            .from(\"小姐姐的邮箱\")\n            .to(\"xiaojiejie@gmail.com\")\n            .html(output)\n            .send();\n}\n\n@Test\npublic void testJetx() throws IOException, PebbleException, MessagingException {\n    JetEngine engine = JetEngine.create();\n    JetTemplate template = engine.getTemplate(\"/register.jetx\");\n\n    Map\u003cString, Object\u003e context = new HashMap\u003cString, Object\u003e();\n    context.put(\"username\", \"biezhi\");\n    context.put(\"email\", \"admin@biezhi.me\");\n    context.put(\"url\", \"\u003ca href='http://biezhi.me'\u003ehttps://biezhi.me/active/asdkjajdasjdkaweoi\u003c/a\u003e\");\n\n    StringWriter writer = new StringWriter();\n    template.render(context, writer);\n    String output = writer.toString();\n    System.out.println(output);\n\n    OhMyEmail.subject(\"这是一封测试Jetx模板邮件\")\n            .from(\"小姐姐的邮箱\")\n            .to(\"xiaojiejie@gmail.com\")\n            .html(output)\n            .send();\n}\n```\n\n### 邮件模版\n\n```html\n\u003cdiv\u003e\n    \u003cp\u003e亲爱的\u003cb\u003e{{ username }}\u003c/b\u003e, 欢迎加入 biezhi !\u003c/p\u003e\n    \u003cp\u003e当您收到这封信的时候，您已经可以正常登录了。\u003c/p\u003e\n    \u003cp\u003e请点击链接登录首页: \u003ca href='http://www.baidu.com'\u003ehttp://biezhi.me/xxxxx\u003c/a\u003e\u003c/p\u003e\n    \u003cp\u003e如果您的 email 程序不支持链接点击，请将上面的地址拷贝至您的浏览器(如IE)的地址栏进入。\u003c/p\u003e\n    \u003cp\u003e如果您还想申请管理员权限，可以联系管理员 {{ email }}\u003c/p\u003e\n    \u003cp\u003e我们对您产生的不便，深表歉意。\u003c/p\u003e\n    \u003cp\u003e希望您在 biezhi 系统度过快乐的时光!\u003c/p\u003e\n    \u003cp\u003e\u003c/p\u003e\n    \u003cp\u003e-----------------------\u003c/p\u003e\n    \u003cp\u003e\u003c/p\u003e\n    \u003cp\u003e(这是一封自动产生的email，请勿回复。)\u003c/p\u003e\n\u003c/div\u003e\n```\n\n## 问题建议\n\n- 我的邮箱：`biezhi.me#gmail.com`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellokaton%2Foh-my-email","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellokaton%2Foh-my-email","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellokaton%2Foh-my-email/lists"}