Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = make(Config)
DefaultConfig is the config used when using functions New, Add, and Parse. This helps keep boilerplate code to a minimum.
Functions ¶
Types ¶
type Attachment ¶ added in v0.3.0
Attachment contains file data for an email attachment
type Config ¶ added in v0.3.0
Config is a map of Forms used when parsing a submission to load the correct form settings and emails.
type Email ¶ added in v0.4.0
type Email struct {
// ID is used when looking up SMTP settings.
// It is case-insensitive but will be matched as UPPERCASE. ex: SMTP_FORM-ID_HOST.
ID string
To string
From string
Cc []string
Bcc []string
ReplyTo string
Subject string
// Template is a go html template to be used when generating the email.
Template string
}
Email contains all the setting to send an email
type Form ¶ added in v0.3.0
type Form struct {
// ID is a case-insensitive string used to look up forms while parsing a submission. It will be matched to a submission's _form_name field.
// If ID is not set, a case-insensitive version of Name will be used for matching instead.
ID string
// Name is a way to store a "Pretty" version of the form ID.
Name string
// Emails is a list of emails. Generally you want to use the AddEmail method instead of adding emails directly.
Emails []Email
// Redirect is used when with the default handlers to return 303 See Other and points the browser to the set value.
Redirect string
// When ReCAPTCHA is set to true the default handlers with verify the g-recaptcha-response field.
ReCAPTCHA bool
// contains filtered or unexported fields
}
Form is for settings that should be set per submission but not per email. Such as redirects and ReCAPTCHA.
func New ¶ added in v0.5.2
New creates a new Form and adds it to the default config. It also automatically sets the name to the ID and adds ignores the form name and recaptcha fields.
type Submission ¶ added in v0.3.0
type Submission struct {
// Form is the form this submission submitted as.
Form *Form
// Order is a list of the fields in the original order of submisson.
// Maps in go are sorted alphabetically which causes readability issues in the generated emails. Note only first level elements are ordered.
// The fields set using Form.Ignore will be removed from this list.
Order []string
// Values contains the submitted form data.
Values map[string]interface{}
// Attachments is a list of files to be attached to the email
Attachments []Attachment
}
Submission is the unmarshaled version on the form submission. It contains the submitted values and the form settings needed for sending emails.
func Parse ¶ added in v0.5.0
func Parse(contentType, body string) (*Submission, error)
Parse creates a submission using the default config.
func (*Submission) Send ¶ added in v0.3.0
func (s *Submission) Send() error
Send sends all the emails for this form
