Skip to content

go-zwbc/emailszh

Repository files navigation

GitHub Workflow Status (branch) GoDoc Coverage Status Supported Go Versions GitHub Release Go Report Card

emailszh

Chinese-named emails sending package based on gomail.v2, making emails operations intuitive with Chinese API.


CHINESE README

中文说明

Main Features

📧 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

Installation

go get github.com/go-zwbc/emailszh

Quick Start

Basic Text Emails

package 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)
    }
}

HTML Emails

// 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 with Attachments

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)

Multiple Recipients (Cc and Bcc)

// 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)

API Reference

Sender Types

  • S发送者: Sending information including SMTP configuration
  • S发送者s: Sending list type
  • Get拨号器(): Get SMTP dialer instance
  • Sen发邮件(): Send emails message
  • Xqt发邮件(): Alias of Sen发邮件
  • Act发邮件(): Alias of Sen发邮件

Recipient Types

  • R接收者: Recipient information (address and name)
  • R接收者s: Recipient list type
  • T收件目标: Complete recipient target (To, Cc, Bcc)
  • New接收者(): Create recipient instance
  • New收件目标(): Create target with To, Cc, and Bcc
  • New目标单收件(): Create target with single recipient
  • New目标单收件和密送(): Create target with To and Bcc
  • New目标首个收件其余密送(): First as To, rest as Bcc

Content Types

  • C邮件内容: Emails message content
  • New文本内容(): Create plain text content
  • New网页内容(): Create HTML content

Message Creation

  • New邮件(): Create complete emails message with subject, content, and target

Construction Operations

  • O邮件构建器: Emails construction with fluent API
  • New邮件构建器(): Create new construction instance
  • New构建器(): Create construction from existing gomail message
  • Set标题(): Set emails subject
  • Set内容(): Set emails message content
  • Set发送者(): Set sending info
  • Set接收者(): Set single recipient
  • Set目标(): Set complete recipient target
  • Set抄送至(): Set Cc recipients
  • Set密送至(): Set Bcc recipients
  • Set附件(): Add attachment
  • Get邮件(): Get constructed emails message

SMTP Configuration

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
QQ smtp.qq.com 465 SSL

Note: Most emails services require app-specific passwords instead of account passwords.

Requirements

  • Go 1.25 or higher
  • Dependencies: gomail.v2, zaplog

📄 License

MIT License - see LICENSE.


💬 Contact & Feedback

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

🔧 Development

New code contributions, follow this process:

  1. Fork: Fork the repo on GitHub (using the webpage UI).
  2. Clone: Clone the forked project (git clone https://github.com/yourname/repo-name.git).
  3. Navigate: Navigate to the cloned project (cd repo-name)
  4. Branch: Create a feature branch (git checkout -b feature/xxx).
  5. Code: Implement the changes with comprehensive tests
  6. Testing: (Golang project) Ensure tests pass (go test ./...) and follow Go code style conventions
  7. Documentation: Update documentation to support client-facing changes
  8. Stage: Stage changes (git add .)
  9. Commit: Commit changes (git commit -m "Add feature xxx") ensuring backward compatible code
  10. Push: Push to the branch (git push origin feature/xxx).
  11. PR: Open a merge request on GitHub (on the GitHub webpage) with detailed description.

Please ensure tests pass and include relevant documentation updates.


🌟 Support

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! 🎉🎉🎉

About

使用go语言收发邮件。该组织下所有项目均使用中文编程。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published