Documentation
¶
Index ¶
Constants ¶
const MaxFilenameBytes = 255
MaxFilenameBytes bounds a file's name CheckFilename takes: written into Content-Type and Content-Disposition, its every byte percent-encoded at worst, it keeps either line well within the 998 octets RFC 5322 allows one.
Variables ¶
This section is empty.
Functions ¶
func CheckFilename ¶ added in v1.117.0
CheckFilename refuses, as ErrValidationError, a name a file is not to be attached under: an empty one, "." or "..", one longer than MaxFilenameBytes or not UTF-8, and one with a control character, a format character (a bidirectional one, as in "invoice\u202efdp.exe", or one that shows as nothing, as a zero-width space), a line or paragraph separator -- each lets a name display as other than it is -- a quote, a backslash or a slash: a path's separators, and what Attachment would write encoded or escaped where mail clients read either differently. A name taken from someone else is checked before it is attached.
Types ¶
type Body ¶
type Body struct {
Content []byte
ContentType string
Headers []*message_header.Header
Parts []*Body
Subtype string
}
func Attachment ¶
Attachment is a part carrying the content, base64, as a file of the content type, named filename when one is given. A content type that is not one, or not given, is application/octet-stream, rather than written as it is: what follows a line break in it would be a header of its own; one with a parameter that does not parse, or that parses but cannot be written again, is kept without its parameters. The name is written as a parameter of Content-Type and of Content-Disposition, quoted where it needs to be, and encoded as RFC 2231 has it where it is not printable ASCII.
type Message ¶
type Message struct {
From *mail.Address
To []*mail.Address
Cc []*mail.Address
Bcc []*mail.Address
Subject string
Body *Body
ReplyTo []*mail.Address
Domain string
Headers []*message_header.Header
// Date is when the message is dated, in its own zone; the time it is written, if zero.
Date time.Time
}