Skip to content

Commit a02393f

Browse files
authored
Merge pull request #35 from go-pkgz/docs/mailto-url-encoding-note
Document URL encoding requirement for mailto query parameters
2 parents 5bd4344 + d7da18a commit a02393f

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func main() {
4949

5050
`mailto:` [scheme](https://datatracker.ietf.org/doc/html/rfc6068) is supported. Only `subject` and `from` query params are used.
5151

52+
**Note:** Query parameter values must be URL-encoded. In particular, email addresses containing `+` (e.g. `noreply+tag@example.com`) must use `%2B`, otherwise `+` is interpreted as a space. Use `url.QueryEscape` for all parameter values.
53+
5254
Examples:
5355

5456
- `mailto:"John Wayne"<john@example.org>?subject=test-subj&from="Notifier"<notify@example.org>`

email.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func NewEmail(smtpParams SMTPParams) *Email {
8181
// with "mailto:" schema.
8282
// "unsubscribeLink" passed as a header, https://support.google.com/mail/answer/81126 -> "Use one-click unsubscribe"
8383
//
84+
// Note: query parameter values in the mailto URL must be properly URL-encoded. In particular, email addresses
85+
// containing "+" (e.g. "noreply+tag@example.com") must use "%2B" instead, otherwise "+" is interpreted as a space
86+
// per standard URL query string parsing. Use url.QueryEscape for all parameter values.
87+
//
8488
// Example:
8589
//
8690
// - mailto:"John Wayne"<john@example.org>?subject=test-subj&from="Notifier"<notify@example.org>

0 commit comments

Comments
 (0)