Demo address: http://mail.hocg.in, Log in using any of your email addresses.
Default permissions have been configured. After logging in, you can read/send emails: test@hocg.in 和 test2@hocg.in
1. Create database
# Create database
npx wrangler d1 create yourself-email
# Write the database configuration displayed on the console pages/wrangler.toml and workers/wrangler.toml to [[d1_databases]]
cd pages
# Execute table creation statement
npx wrangler d1 execute yourself-email --remote --file=./migrations/0001_create_table.sql
# =========== ⚠️ Configure permissions ===========
# Configure super administrator permissions
npx wrangler d1 execute yourself-email --remote --command "INSERT INTO UserConfig(email, is_super_admin, read_mail, sent_mail) VALUES ('hocgin@gmail.com', true, '*', '*')";
# Configure default login account permissions
npx wrangler d1 execute yourself-email --remote --command "INSERT INTO UserConfig(email, is_super_admin, read_mail, sent_mail) VALUES ('*', false, 'test@hocg.in', 'test@hocg.in')";
2. Deploy email Workers / incoming mail
cd workers
npm run deploy
Select database yourself-email
, and set the variable name to DB
- logIn Cloudflare Choose the domain name you want to use
- Enter the menu on the left Email > Email Routing > Email Workers,Enabled Email Routing
- Specify forward to
yourself-email-workers
- Configure domain DNS
3. Deploy email Pages / send email
cd pages
npm run deploy
Select database yourself-email
, and set the variable name to DB
Configure to allow sending emails through the pages domain name
record | type | content |
---|---|---|
@ | TXT | v=spf1 a mx include:relay.mailchannels.net ~all |
_mailchannels | TXT | v=mc1 cfid=yourself-email-pages.pages.dev |
DKIM is a DNS record that helps prevent email spoofing and can improve email deliverability.
# Generate private key
openssl genrsa 2048 | tee private_key.pem | openssl rsa -outform der | openssl base64 -A > private_key.txt
# Generate DNS records
echo -n "v=DKIM1;p=" > dkim_record.txt && openssl rsa -in private_key.pem -pubout -outform der | openssl base64 -A >> dkim_record.txt
record | type | content | explanation |
---|---|---|---|
_dmarc | TXT | v=DMARC1; s=mailchannels; p=reject; adkim=s; aspf=s; rua=mailto:xxx@gmail.com; ruf=mailto:xxx@gmail.com pct=100; fo=1; | Strict mode, please replace yourself to the mailbox |
_dmarc | TXT | v=DMARC1; s=mailchannels; p=none; adkim=r; aspf=r; | Relaxed mode |
mailchannels._domainkey | TXT | dkim_record.txt content |
- v=DMARC1: Specify the version of the DMARC record, here is version 1.
- s=mailchannels: Indicates the domain of the DMARC policy, here is mailchannels.
- p=reject: defines what the recipient should do if the email fails DMARC verification. Here is reject, which means directly rejecting the email.
- adkim=s: specifies the domain name authentication signature (DKIM) policy, here is s (strict), which means that the DKIM signature must be verified.
- aspf=s: Specifies the policy of the Sender Policy Framework (SPF), here it is s (strict), which means that the SPF record must be verified.
- rua=mailto:YYY: Specifies the email address for failure reports. When an email fails DMARC verification, the recipient sends a report to this address. mailto:YYY Needs to be replaced with actual email address.
- ruf=mailto:YYY: Specifies the email address of the failure report, which is used to send more detailed failure information. Likewise, mailto:YYY needs to be replaced with the actual email address.
- pct=100: Defines the percentage of emails checked by DMARC. Here it is 100, meaning all emails will be checked.
- fo=1: Specifies options for failure reporting. 1 means to report all failed records instead of only those that failed the DMARC policy. (Note: the complete definition of the fo parameter seems to be missing from the string you provided, typically it may contain multiple options, such as 1 to request a complete failure report)
- DKIM_DOMAIN: Email domain, 如: hocg.in
- DKIM_SELECTOR:
dmarc
中 s= Field content, 填mailchannels
- DKIM_PRIVATE_KEY:
private_key.txt
document content
ToDoList
- Mark as read
- Archive
- Recycle Bin
- Recycle bin, complete deletion
- Add labels to emails
- Email details, the sender displays the email header information
- Email details, query communication history with user X
- Permission design and implementation
- User status, query the unread quantity and authorized account list
- Support rich text editor
- Organize/Develop API interface
- Mobile support