Chinese-named email sending library based on gomail.v2, making email operations intuitive with Chinese API.
📧 Chinese API: Intuitive Chinese function and type names ⚡ Fluent Builder: Chain-style email construction 🎯 Rich Recipients: Support To, Cc, and Bcc recipients 📎 Attachment Support: Easy file attachment handling 🔧 SMTP Configuration: Flexible sender configuration with SMTP settings
go get github.com/go-zwbc/emailzhpackage main
import (
"github.com/go-zwbc/emailzh"
)
func main() {
// Create sender
sender := &emailzh.S发送者{
A地址: "[email protected]",
N昵称: "Sender Name",
H主机: "smtp.example.com",
P端口: 465,
U账号: "[email protected]",
W密码: "password",
}
// Create recipient
recipient := emailzh.New接收者("[email protected]", "Recipient Name")
// Build and send email
email := emailzh.New邮件构建器().
Set标题("Email Subject").
Set内容(emailzh.New文本内容("Email body content")).
Set发送者(sender).
Set目标(emailzh.New目标单收件(recipient)).
Get邮件()
// Send email
err := sender.Sen发邮件(email)
if err != nil {
panic(err)
}
}// Create HTML content
htmlContent := emailzh.New网页内容("<h1>Welcome</h1><p>This is HTML content</p>")
// Build email
email := emailzh.New邮件构建器().
Set标题("HTML Email").
Set内容(htmlContent).
Set发送者(sender).
Set目标(emailzh.New目标单收件(recipient)).
Get邮件()
sender.Sen发邮件(email)email := emailzh.New邮件构建器().
Set标题("Email with Attachment").
Set内容(emailzh.New文本内容("Please check the attachment")).
Set发送者(sender).
Set目标(emailzh.New目标单收件(recipient)).
Set附件("/path/to/file.pdf").
Get邮件()
sender.Sen发邮件(email)// Create multiple recipients
to := emailzh.New接收者("[email protected]", "To User")
cc1 := emailzh.New接收者("[email protected]", "CC User 1")
cc2 := emailzh.New接收者("[email protected]", "CC User 2")
bcc1 := emailzh.New接收者("[email protected]", "BCC User 1")
// Create target with Cc and Bcc
target := emailzh.New收件目标(
to,
[]*emailzh.R接收者{cc1, cc2},
[]*emailzh.R接收者{bcc1},
)
email := emailzh.New邮件构建器().
Set标题("Email with Multiple Recipients").
Set内容(emailzh.New文本内容("Content")).
Set发送者(sender).
Set目标(target).
Get邮件()
sender.Sen发邮件(email)S发送者: Sender information including SMTP configurationGet拨号器(): Get SMTP dialerSen发邮件(): Send email message
R接收者: Recipient information (address and name)T收件目标: Complete recipient target (To, Cc, Bcc)New接收者(): Create recipientNew目标单收件(): Create target with single recipientNew目标单收件和密送(): Create target with To and BccNew目标首个收件其余密送(): First as To, rest as Bcc
C邮件内容: Email body contentNew文本内容(): Create plain text contentNew网页内容(): Create HTML content
O邮件构建器: Email builder with fluent APISet标题(): Set email subjectSet内容(): Set email body contentSet发送者(): Set senderSet接收者(): Set single recipientSet目标(): Set complete recipient targetSet抄送至(): Set Cc recipientsSet密送至(): Set Bcc recipientsSet附件(): Add attachmentGet邮件(): Get built email message
Common SMTP settings:
| Service | SMTP Host | Port | Security |
|---|---|---|---|
| Gmail | smtp.gmail.com | 465 | SSL |
| Outlook | smtp.office365.com | 587 | TLS |
| 163 | smtp.163.com | 465/994 | SSL |
| smtp.qq.com | 465 | SSL |
Note: Most email services require app-specific passwords instead of account passwords.
- Go 1.25 or higher
- Dependencies: gomail.v2, zaplog
MIT License. See LICENSE.
Contributions are welcome! Report bugs, suggest features, and contribute code:
- 🐛 Found a mistake? Open an issue on GitHub with reproduction steps
- 💡 Have a feature idea? Create an issue to discuss the suggestion
- 📖 Documentation confusing? Report it so we can improve
- 🚀 Need new features? Share the use cases to help us understand requirements
- ⚡ Performance issue? Help us optimize through reporting slow operations
- 🔧 Configuration problem? Ask questions about complex setups
- 📢 Follow project progress? Watch the repo to get new releases and features
- 🌟 Success stories? Share how this package improved the workflow
- 💬 Feedback? We welcome suggestions and comments
New code contributions, follow this process:
- Fork: Fork the repo on GitHub (using the webpage UI).
- Clone: Clone the forked project (
git clone https://github.com/yourname/repo-name.git). - Navigate: Navigate to the cloned project (
cd repo-name) - Branch: Create a feature branch (
git checkout -b feature/xxx). - Code: Implement the changes with comprehensive tests
- Testing: (Golang project) Ensure tests pass (
go test ./...) and follow Go code style conventions - Documentation: Update documentation to support client-facing changes and use significant commit messages
- Stage: Stage changes (
git add .) - Commit: Commit changes (
git commit -m "Add feature xxx") ensuring backward compatible code - Push: Push to the branch (
git push origin feature/xxx). - PR: Open a merge request on GitHub (on the GitHub webpage) with detailed description.
Please ensure tests pass and include relevant documentation updates.
Welcome to contribute to this project via submitting merge requests and reporting issues.
Project Support:
- ⭐ Give GitHub stars if this project helps you
- 🤝 Share with teammates and (golang) programming friends
- 📝 Write tech blogs about development tools and workflows - we provide content writing support
- 🌟 Join the ecosystem - committed to supporting open source and the (golang) development scene
Have Fun Coding with this package! 🎉🎉🎉