github.com/gogf/gf@v1.16.9/.example/net/gsmtp/gsmtp_sendMail.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/gogf/gf.
     6  package main
     7  
     8  import (
     9  	"fmt"
    10  
    11  	"github.com/gogf/gf/net/gsmtp"
    12  )
    13  
    14  func main() {
    15  
    16  	// create the SMTP connection
    17  	smtpConnection := gsmtp.New("smtp.exmail.qq.com", "smtpUser@smtp.exmail.qq.com", "smtpPassword")
    18  	// or you can specify the port explicitly
    19  	// smtpConnection := smtp.New("smtp.exmail.qq.com:25", "smtpUser@smtp.exmail.qq.com", "smtpPassword")
    20  
    21  	// send the Email
    22  	fmt.Println(smtpConnection.SendMail("sender@local.host", "recipient1@domain.com;recipientN@anotherDomain.cn", "This is subject", "Hi! <br><br> This is body"))
    23  
    24  }