...

Source file src/gitlab.hexacode.org/go-libs/mailer/example/main.go

Documentation: gitlab.hexacode.org/go-libs/mailer/example

     1  /*
     2   * Hexacode Mailer
     3   * Package: gitlab.hexacode.org/go-libs/mailer
     4   * Maintainer: Azzis Arswendo <azzis@hexacode.org>
     5   *
     6   * Copyright (C) 2023 Hexacode Teknologi Indonesia
     7   * All Rights Reserved
     8   */
     9  
    10  package main
    11  
    12  import (
    13  	"gitlab.hexacode.org/go-libs/hctypes"
    14  	"gitlab.hexacode.org/go-libs/mailer"
    15  )
    16  
    17  func main() {
    18  	// Create a new template
    19  	// Please see https://github.com/noirbizarre/gonja for more details template
    20  	tmpl, err := mailer.NewTemplate("Hello {{ name }}!")
    21  	if err != nil {
    22  		panic(err)
    23  	}
    24  
    25  	// Create a new sender
    26  	sender := mailer.NewSender("Example Sender", "example-sender@gmail.com", "password", "smtp.gmail.com", 587, tmpl)
    27  
    28  	// Send an email
    29  	err = sender.SendEmail("example-recipient@gmail.com", "Example Subject", hctypes.Dict{"name": "John Doe"})
    30  	if err != nil {
    31  		panic(err)
    32  	}
    33  }
    34  

View as plain text