Go语言smtp模块发纯文本文件

2021-11-01 10:40:36 浏览数 (2)

代码语言:javascript复制
package main

import (  
    "fmt"  
    "net/smtp"  
)  

func main() {  
    auth := smtp.PlainAuth("text/plain", "fyxichen@163.com", "123456", "smtp.163.com")  
    to := []string{"123456@qq.com"}  
    msg := []byte(`To:123456@qq.com  
From:czxichen@163.com  
Subject:测试  
Content-Type: text/plain;  
charset=UTF-8"  

this is test mail`)  
    err := smtp.SendMail("smtp.163.com:25", auth, "fyxichen@163.com", to, msg)  
    fmt.Println(err)  
}  </pre> 

0 人点赞