Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

2.5 KB
Raw Blame
package emailing

import "github.com/SigNoz/signoz/pkg/factory"

type Config struct {
	Enabled   bool      `mapstructure:"enabled"`
	Templates Templates `mapstructure:"templates"`
	SMTP      SMTP      `mapstructure:"smtp"`
}

type Templates struct {
	Directory string `mapstructure:"directory"`
	Format    Format `mapstructure:"format"`
}

type Format struct {
	Header Header `mapstructure:"header"`
	Help   Help   `mapstructure:"help"`
	Footer Footer `mapstructure:"footer"`
}

type Header struct {
	Enabled bool   `mapstructure:"enabled"`
	LogoURL string `mapstructure:"logo_url"`
}

type Help struct {
	Enabled bool   `mapstructure:"enabled"`
	Email   string `mapstructure:"email"`
}

type Footer struct {
	Enabled bool `mapstructure:"enabled"`
}

type SMTP struct {
	Address string            `mapstructure:"address"`
	From    string            `mapstructure:"from"`
	Hello   string            `mapstructure:"hello"`
	Headers map[string]string `mapstructure:"headers"`
	Auth    SMTPAuth          `mapstructure:"auth"`
	TLS     SMTPTLS           `mapstructure:"tls"`
}

type SMTPAuth struct {
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	Secret   string `mapstructure:"secret"`
	Identity string `mapstructure:"identity"`
}

type SMTPTLS struct {
	Enabled            bool   `mapstructure:"enabled"`
	InsecureSkipVerify bool   `mapstructure:"insecure_skip_verify"`
	CAFilePath         string `mapstructure:"ca_file_path"`
	KeyFilePath        string `mapstructure:"key_file_path"`
	CertFilePath       string `mapstructure:"cert_file_path"`
}

func NewConfigFactory() factory.ConfigFactory {
	return factory.NewConfigFactory(factory.MustNewName("emailing"), newConfig)
}

func newConfig() factory.Config {
	return &Config{
		Enabled: false,
		Templates: Templates{
			Directory: "/root/templates/email",
			Format: Format{
				Header: Header{
					Enabled: false,
					LogoURL: "",
				},
				Help: Help{
					Enabled: false,
					Email:   "",
				},
				Footer: Footer{
					Enabled: false,
				},
			},
		},
		SMTP: SMTP{
			Address: "localhost:25",
			From:    "",
			Hello:   "",
			Headers: map[string]string{},
			Auth: SMTPAuth{
				Username: "",
				Password: "",
				Secret:   "",
				Identity: "",
			},
			TLS: SMTPTLS{
				Enabled:            false,
				InsecureSkipVerify: false,
				CAFilePath:         "",
				KeyFilePath:        "",
				CertFilePath:       "",
			},
		},
	}
}

func (c Config) Validate() error {
	return nil
}

func (c Config) Provider() string {
	if c.Enabled {
		return "smtp"
	}

	return "noop"
}