Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "net/smtp"
- "strconv"
- )
- type EmailConfig struct {
- Username string
- Password string
- Host string
- Port int
- }
- func main() {
- // authentication configuration
- smtpHost := "smtp.mail.ru"
- smtpPort := 587
- smtpPass := "пароль от почты отправимтеля" // пароль от почты mail.ru
- smtpUser := "почта отправителя" // почта mail.ru
- emailConf := &EmailConfig{smtpUser, smtpPass, smtpHost, smtpPort}
- emailauth := smtp.PlainAuth("", emailConf.Username, emailConf.Password, emailConf.Host)
- sender := "почта отправителя" // отправитель
- receivers := []string{
- "почта получателя",
- } // получатели
- message := []byte("текст письма") // your message
- // send out the email
- err := smtp.SendMail(smtpHost+":"+strconv.Itoa(emailConf.Port), //convert port number from int to string
- emailauth,
- sender,
- receivers,
- message,
- )
- if err != nil {
- fmt.Println(err)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement