通过网页调用Resend API发送邮件

William Peter Matthew
大约 1 分钟...

Resend Mail Webpageopen in new window

一个通过网页调用Resend API发送邮件的项目。

Docker PullsDocker Image SizeDocker Image Version

使用Docker Compose构建,使用Python Flask框架。

第一步

创建一个 Resendopen in new window 账号。

第二步

添加一个域名到你的 Resend 账号。

第三步

创建你的账号的 API Key。

第四步

克隆这个仓库。

git clone https://github.com/WilliamPeterMatthew/resend-mail-webpage.git

第五步

创建一个 .env 文件。

cp .env.example .env

第六步

修改 .env 文件。

变量名描述示例
RESEND_API_KEY在第三步中获得的API Keyre_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;
}

评论