您现在的位置是:首页 > 技术教程 正文

Go:实现SMTP邮件发送订阅功能(包含163邮箱、163企业邮箱、谷歌gmail邮箱)

admin 阅读: 2024-03-18
后台-插件-广告管理-内容页头部广告(手机)

需求很简单,就是用户输入自己的邮箱后,使用官方邮箱给用户发送替邮件模版

在这里插入图片描述

目录

  • 前置
    • 邮件模版
    • 邮箱开启SMTP服务
      • 163邮箱
      • 163企业邮箱
      • 谷歌gmail邮箱
      • 腾讯企业邮箱-失败
      • 其他邮箱-未操作
  • 邮件发送核心代码
    • config.yaml配置
    • 读取邮件相关配置
    • 发送邮件
  • 附录

前置

邮件模版

邮件模版类似如下图发来的欢迎加入的模版
在这里插入图片描述

这里我们使用html格式存储模版,上图源码如下

<html lang="en-US" xmlns:th="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>emailtitle> <style> a{ color: #ECC94B !important; } .foot-text{ color: rgba(0, 0, 0, 0.50) !important; } .im{ color:rgba(0,0,0,0.86) !important; } .center { display: flex; justify-content: center; align-items: center; } style> head> <body style="background-color: white;"> <div style="width: 640px;height: auto;border-radius: 5px;margin: 0 auto;position: relative; padding-bottom: 80px; padding-top: 20px"> <div> <img width="640" src="file:///Users/yanzhixing/Downloads/My/文档/HatchfulExport-All/linkedin_banner_image_2.png" alt=""> div> <div style="color: rgba(0,0,0,0.86);font-family: 'Roboto','Century Gothic', 'Trebuchet MS', 'Hiragino Sans GB', 微软雅黑, 'Microsoft Yahei', Tahoma, Helvetica, Arial, 'SimSun', sans-serif;font-size: 16px;margin: 10px auto 0px"> <h2 style="font-size: 20px;font-weight: 700; color: #000">Dear KunZhi Fans,h2> <div> <p style="margin: 16px 0; ">Welcome to the family! We are glad to have you on board as a subscriber to my blog.p > <p style="font-weight: 600; color: #000;">Get the latest on <a style="color: #000" href="https://kunzhi.blog.csdn.net/">CSDNa> and give me a follow if you haven't already.p> <p style="margin: 16px 0"> <p style="font-weight: 600; color: #000">
标签:
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

在线投稿:投稿 站长QQ:1888636

后台-插件-广告管理-内容页尾部广告(手机)
关注我们

扫一扫关注我们,了解最新精彩内容

搜索