通过网页调用Resend API发送邮件
大约 1 分钟...
Resend Mail Webpage
一个通过网页调用Resend API发送邮件的项目。
使用Docker Compose构建,使用Python Flask框架。
第一步
创建一个 Resend 账号。
第二步
添加一个域名到你的 Resend 账号。
第三步
创建你的账号的 API Key。
第四步
克隆这个仓库。
git clone https://github.com/WilliamPeterMatthew/resend-mail-webpage.git
第五步
创建一个 .env
文件。
cp .env.example .env
第六步
修改 .env
文件。
变量名 | 描述 | 示例 |
---|---|---|
RESEND_API_KEY | 在第三步中获得的API Key | re_1234567890aBcDeFgHiJkLmNoPqEsTuVw |
SITE_PASSWORD | 网站密码,防止其他人滥用 | P@ssw0rd |
PORT | 外部访问的端口 | 5827 |
第七步
运行项目。
docker-compose up -d
你也可以使用预构建的镜像而不是本地构建。
docker-compose -f docker-compose-prebuild.yml up -d
恭喜
现在你可以在第六步中设置的端口访问网页了。
可选
你可以配置Apache或Nginx反向代理到端口80。
Apache示例:
<VirtualHost *:80>
ServerName example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:<你在第六步中设置的端口>/
ProxyPassReverse / http://localhost:<你在第六步中设置的端口>/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Nginx示例:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:<你在第六步中设置的端口>;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_log /var/log/nginx/resendmail_error.log;
access_log /var/log/nginx/resendmail_access.log;
}
评论