Skip to content

通过实现一个可以发送邮件工具,达到学习目的。

License

Notifications You must be signed in to change notification settings

quixote-liu/email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

email

参考github.com/jordan-wright/email和smtp协议写的一个可以发送邮件的工具,主要以学习为目的。其发送普通邮件示例:

    import (
        "net/smtp"
        "github.com/quixote-liu/email"
    )

    func main() {
        e := email.Email{
            From:     "your_email@mail.com",
            To:       []string{"target_email@qq.com"},
            Subject:  "This is Subject",
            Addr:     "smtp.example.com:25",
        }

        if err := e.AttachFile("./filename.txt"); err != nil {
        	log.Fatal(err)
        }

        auth := smtp.PlainAuth("", "your_email@mail.com", "your_password", "smtp.example.com")
        message := []byte("hello, world")

        err := e.SetAuth(auth).WriteText(message).Send()
        if err != nil {
            log.Fatal(err)
        }

        // reset email message, include attchments.
        e.Reset()
    }

About

通过实现一个可以发送邮件工具,达到学习目的。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages