Chinese-named emails sending package based on gomail.v2, making emails operations intuitive with Chinese API.
📧 Chinese API: Intuitive Chinese function and type names ⚡ Fluent Builder: Chain-style emails construction 🎯 Rich Recipients: Support To, Cc, and Bcc recipients 📎 Attachment Support: Simple file attachment handling 🔧 SMTP Configuration: Flexible sender configuration with SMTP settings
go get github.com/go-zwbc/emailszhpackage main
import (
"github.com/go-zwbc/emailszh"
)
func main() {
// Create sender
sender := &emailszh.S发送者{
M邮箱: "[email protected]",
N昵称: "Sender Name",
H主机: "smtp.example.com",
P端口: 465,
U账号: "[email protected]",
P密码: "password",
}
// Create recipient
recipient := emailszh.New接收者("[email protected]", "Recipient Name")
// Build and send emails
emails := emailszh.New邮件构建器().
Set标题("Emails Subject").
Set内容(emailszh.New文本内容("Emails content text")).
Set发送者(sender).
Set目标(emailszh.New目标单收件(recipient)).
Get邮件()
// Send emails
err := sender.Sen发邮件(emails)
if err != nil {
panic(err)
}
}// Create HTML content
htmlContent := emailszh.New网页内容("<h1>Welcome</h1><p>This is HTML content</p>")
// Build emails
emails := emailszh.New邮件构建器().
Set标题("HTML Emails").
Set内容(htmlContent).
Set发送者(sender).
Set目标(emailszh.New目标单收件(recipient)).
Get邮件()
sender.Sen发邮件(emails)emails := emailszh.New邮件构建器().
Set标题("Emails with Attachment").
Set内容(emailszh.New文本内容("Please check the attachment")).
Set发送者(sender).
Set目标(emailszh.New目标单收件(recipient)).
Set附件("/path/to/file.pdf").
Get邮件()
sender.Sen发邮件(emails)// Create multiple recipients
to := emailszh.New接收者("[email protected]", "To User")
cc1 := emailszh.New接收者("[email protected]", "CC User 1")
cc2 := emailszh.New接收者("[email protected]", "CC User 2")
bcc1 := emailszh.New接收者("[email protected]", "BCC User 1")
// Create target with Cc and Bcc
target := emailszh.New收件目标(
to,
[]*emailszh.R接收者{cc1, cc2},
[]*emailszh.R接收者{bcc1},
)
emails := emailszh.New邮件构建器().
Set标题("Emails with Multiple Recipients").
Set内容(emailszh.New文本内容("Content")).
Set发送者(sender).
Set目标(target).
Get邮件()
sender.Sen发邮件(emails)S发送者: Sending information including SMTP configurationS发送者s: Sending list typeGet拨号器(): Get SMTP dialer instanceSen发邮件(): Send emails messageXqt发邮件(): Alias of Sen发邮件Act发邮件(): Alias of Sen发邮件
R接收者: Recipient information (address and name)R接收者s: Recipient list typeT收件目标: Complete recipient target (To, Cc, Bcc)New接收者(): Create recipient instanceNew收件目标(): Create target with To, Cc, and BccNew目标单收件(): Create target with single recipientNew目标单收件和密送(): Create target with To and BccNew目标首个收件其余密送(): First as To, rest as Bcc
C邮件内容: Emails message contentNew文本内容(): Create plain text contentNew网页内容(): Create HTML content
New邮件(): Create complete emails message with subject, content, and target
O邮件构建器: Emails construction with fluent APINew邮件构建器(): Create new construction instanceNew构建器(): Create construction from existing gomail messageSet标题(): Set emails subjectSet内容(): Set emails message contentSet发送者(): Set sending infoSet接收者(): Set single recipientSet目标(): Set complete recipient targetSet抄送至(): Set Cc recipientsSet密送至(): Set Bcc recipientsSet附件(): Add attachmentGet邮件(): Get constructed emails 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 emails 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:
- 🐛 Mistake reports? Open an issue on GitHub with reproduction steps
- 💡 Fresh ideas? Create an issue to discuss
- 📖 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
- 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! 🎉🎉🎉