grpc

package
v1.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2019 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package grpc provides the actual logic for posting emails to queue or to mail servers

Index

Constants

This section is empty.

Variables

View Source
var ExposedConfigs = &forms.Form{
	I18NBundle: lang.Bundle(),
	Groups: []*forms.Group{{
		Label: "Mail.Config.Title",
		Fields: []forms.Field{
			&forms.FormField{
				Name:        "from",
				Label:       "Mail.Config.From.Label",
				Description: "Mail.Config.From.Description",
				Mandatory:   true,
				Type:        forms.ParamString,
			},
			&forms.SwitchField{
				Name:        "sender",
				Label:       "Mail.Config.Mailer.Label",
				Description: "Mail.Config.Mailer.Description",
				Mandatory:   true,
				Default:     "smtp",
				Values: []*forms.SwitchValue{
					{
						Name:  "name",
						Label: "Mail.Config.Sendmail.Label",
						Value: "sendmail",
						Fields: []forms.Field{
							&forms.FormField{
								Name:        "executable",
								Label:       "Mail.Config.Sendmail.Executable.Label",
								Description: "Mail.Config.Sendmail.Executable.Description",
								Mandatory:   true,
								Editable:    false,
								Type:        forms.ParamSelect,
								ChoicePresetList: []map[string]string{
									{"sendmail": "sendmail"},
									{"/usr/bin/sendmail": "/usr/bin/sendmail"},
									{"/usr/sbin/sendmail": "/usr/sbin/sendmail"},
									{"other": "Mail.Config.Sendmail.Executable.Other"},
								},
								Default: "/usr/sbin/sendmail",
							},
						},
					},
					{
						Name:  "name",
						Label: "Mail.Config.Smtp.Label",
						Value: "smtp",
						Fields: []forms.Field{
							&forms.FormField{
								Name:        "host",
								Label:       "Mail.Config.Smtp.Host.Label",
								Description: "Mail.Config.Smtp.Host.Description",
								Mandatory:   true,
								Type:        forms.ParamString,
							},
							&forms.FormField{
								Name:        "port",
								Label:       "Mail.Config.Smtp.Port.Label",
								Description: "Mail.Config.Smtp.Port.Description",
								Mandatory:   true,
								Type:        forms.ParamInteger,
							},
							&forms.FormField{
								Name:        "user",
								Label:       "Mail.Config.Smtp.User.Label",
								Description: "Mail.Config.Smtp.User.Description",
								Mandatory:   true,
								Type:        forms.ParamString,
							},
							&forms.FormField{
								Name:        "password",
								Label:       "Mail.Config.Smtp.Password.Label",
								Description: "Mail.Config.Smtp.Password.Description",
								Mandatory:   true,
								Type:        forms.ParamPassword,
							},
							&forms.FormField{
								Name:        "insecureSkipVerify",
								Label:       "Mail.Config.Smtp.SkipVerify.Label",
								Description: "Mail.Config.Smtp.SkipVerify.Description",
								Mandatory:   false,
								Type:        forms.ParamBool,
							},
						},
					},
					{
						Name:  "name",
						Label: "Mail.Config.SendGrid.Label",
						Value: "sendgrid",
						Fields: []forms.Field{
							&forms.FormField{
								Name:        "apiKey",
								Label:       "Mail.Config.SendGrid.ApiKey.Label",
								Description: "Mail.Config.SendGrid.ApiKey.Description",
								Mandatory:   true,
								Type:        forms.ParamString,
							},
						},
					},
				},
			},
			&forms.FormField{
				Name:        "queue",
				Type:        forms.ParamSelect,
				Label:       "Mail.Config.Queue.Label",
				Description: "Mail.Config.Queue.Description",
				ChoicePresetList: []map[string]string{
					{"boltdb": "Mail.Config.Queue.ValueBolt"},
					{"memory": "Mail.Config.Queue.ValueMemory"},
				},
				Default: "boltdb",
			},
		},
	}},
}
View Source
var (
	// Name is the identifier of this service
	Name = common.SERVICE_GRPC_NAMESPACE_ + common.SERVICE_MAILER
)

Functions

func RegisterQueueJob

func RegisterQueueJob(ctx context.Context) error

RegisterQueueJob adds a job to the scheduler to regularly flush the queue

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(serviceCtx context.Context, conf common.ConfigValues) (*Handler, error)

func (*Handler) ConsumeQueue

ConsumeQueue browses current queue for emails to be sent

func (*Handler) SendMail

func (h *Handler) SendMail(ctx context.Context, req *proto.SendMailRequest, rsp *proto.SendMailResponse) error

SendMail either queues or send a mail directly

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL