Categorygithub.com/demdxx/sendmsg
modulepackage
0.0.0-20240126132054-834dad9e9d6e
Repository: https://github.com/demdxx/sendmsg.git
Documentation: pkg.go.dev

# README

Message sender abstraction

Usage

go get github.com/demdxx/sendmsg
package main

import (
  "fmt"
  "log"

  "github.com/demdxx/sendmsg"
  "github.com/demdxx/sendmsg/email"
  "github.com/demdxx/sendmsg/template"
)

func main() {
  smtpSender, err := email.New(
    email.WithConfig(email.Config{
      URL:         "smtp.gmail.com",
      FromAddress: "[email protected]",
      FromName:    "Mailer",
      Password:    "password",
      Port:        587,
    }),
    // Default vars for all messages
    email.WithVars(map[string]any{
      "company": "My Awesome Company",
    }),
  )

  if err != nil {
    log.Fatal(err)
  }

  // ...
  templateStorage := template.NewDefaultStorage(registerTmpl, resetPasswordTmpl)
  messanger := sendmsg.NewDefaultMessanger(templateStorage).
                       RegisterSender("email", smtpSender)

  // ...
  err := messanger.Send(ctx,
    sendmsg.WithTemplate("register"),
    sendmsg.WithSender("email"),
    sendmsg.WithVars(map[string]any{
      "name": "Mr. Smith", 
      "email": "[email protected]",
    }),
  )
}

TODO

  • Add Telegram sender implementation
  • Add Slack sender implementation
  • Add WhatsApp sender implementation
  • Add Viber sender implementation
  • Add Facebook sender implementation
  • Add Equipos sender implementation
  • Add Line sender implementation
  • Add WeChat sender implementation
  • Add Skype sender implementation
  • Add Signal sender implementation
  • Add Discord sender implementation
  • Add Snapchat sender implementation
  • Add SMS sender implementation
  • Add EMail sender implementation

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewDefaultMessanger creates new messanger.
WithAttaches sets the list of attachments.
WithContent sets the content of the message.
WithMessage sets the message to send.
WithoutSender sets the list of not allowed senders.
WithRecipients sets the list of recipients.
WithSender sets the list of allowed senders.
WithSubject sets the subject of the message.
WithTemplate sets the template name to send.
WithVars sets the list of variables.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
DefaultMessanger implements sendmsg.Messanger interface.
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
Messanger interface for sending messages into abstract channel.
Sender is the interface for sending messages to specific message target like email, sms, etc.

# Type aliases

No description provided by the author