6

jmailer:SpringBoot的发送电子邮件源码案例

 4 months ago
source link: https://www.jdon.com/71346.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

jmailer:SpringBoot的发送电子邮件源码案例 - 极道

随时随地发送电子邮件

  • 可使用 curl、httpie 或脚本发送电子邮件
  • 使用移动应用程序发送电子邮件
  • 使用网站表单发送电子邮件
  • 使用包含电子邮件列表地址的文件发送电子邮件

curl发送
可以使用命令行或脚本发送电子邮件
curl 是一个开源命令行工具和库,用于使用 URL 语法传输数据

curl -H "Content-Type: application/json" -v -X POST -d '{"name":"josdem","email":"[email protected]","message":"Hello from curl!", "template":"message.ftl","token":"userToken"}' 'https://jmailer.josdem.io/emailer/message'

WSLite
Groovy 的轻量级 SOAP 和 REST Web 服务客户端

@Grab('com.github.groovy-wslite:groovy-wslite:1.1.2')

import wslite.rest.RESTClient


def client = new RESTClient("http://jmailer.josdem.io/emailer/")

client.post(path:'message'){

json name:"josdem",email:"[email protected]",message:"Hello from WSLite!",template:"message.ftl",token:"userToken"

}

表单
表单是网页的一个组件,包含表单控件,如文本字段、文本区域和按钮
https://jmailer.josdem.io/form

您可以使用文件发送电子邮件

  • Excel
  • Text File

构建:
cd ${projectHome}/web/src/main/resources/static
npm install

配置:
为了运行应用程序,你需要在$HOME/.jmailer中创建一个名为application-development.yml的YAML文件,文件结构如下:

email:
  username: email
  password: password
  subject: Hello from Jmailer!
  contact: [email protected]
  redirect: https://josdem.io/flyer/jmailer
  whitelist: http://localhost:8080/
  blacklist: 180.76.15.
  homeRequestURL: http://localhost:8080/
  spamTokens:
    - one
  spamNames:
    - one
spring:
  messages:
    basename: i18n/messages
  logging:
    file: jmailer.log
  activemq:
    packages:
      trusted: com.jos.dem.jmailer
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER
api:
  version: 1.0.0
  title: Spring Boot Swagger
  basePackage: com.jos.dem.swagger
  description: Automated JSON API documentation for API's built with Spring
  terms: https://josdem.io/
  • spamTokens 是标记列表,用于过滤电子邮件正文中不需要的垃圾邮件
  • spamNames 是一个标记列表,用于过滤不受欢迎的垃圾邮件发件人姓名

运行:
gradle -Dtoken=userToken -Dspring.config.location=$HOME/.jmailer/application-development.yml :web:bootRun


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK