-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setters: q-encode headers according to RFC1342
Encodes non-ASCII characters using the Q-encoding specified in RFC1342. https://tools.ietf.org/html/rfc1342 Fixes #19.
- Loading branch information
Showing
2 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package mailyak | ||
|
||
import "mime" | ||
|
||
// To sets a list of recipient addresses. | ||
// | ||
// You can pass one or more addresses to this method, all of which are viewable to the recipients. | ||
|
@@ -115,8 +117,9 @@ func (m *MailYak) From(addr string) { | |
// | ||
// From Name <[email protected]> | ||
// | ||
// If name contains non-ASCII characters, it is Q-encoded according to RFC1342. | ||
func (m *MailYak) FromName(name string) { | ||
m.fromName = m.trimRegex.ReplaceAllString(name, "") | ||
m.fromName = mime.QEncoding.Encode("UTF-8", m.trimRegex.ReplaceAllString(name, "")) | ||
} | ||
|
||
// ReplyTo sets the Reply-To email address. | ||
|
@@ -127,6 +130,8 @@ func (m *MailYak) ReplyTo(addr string) { | |
} | ||
|
||
// Subject sets the email subject line. | ||
// | ||
// If sub contains non-ASCII characters, it is Q-encoded according to RFC1342. | ||
func (m *MailYak) Subject(sub string) { | ||
m.subject = m.trimRegex.ReplaceAllString(sub, "") | ||
m.subject = mime.QEncoding.Encode("UTF-8", m.trimRegex.ReplaceAllString(sub, "")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters