Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag to control subject encoding #75

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export interface SendConfig {
*/
internalTag?: string | symbol;
headers: Record<string, string>;
rawSubject?: boolean;
}
```

Expand Down Expand Up @@ -307,6 +308,14 @@ to binary.
This can be used with preprocessors so you can give mail a type, for example
`'registration'`, `'newsletter'` etc. supports symbols and strings.

#### rawSubject

The library always encodes the email subject to quoted-printable to conform to the standards.

Unfortunately, some popular UI clients, for example, Gmail, do not display quoted-printable subjects correctly. Instead, though, they deal perfectly with non-ascii values in the subject, displaying them correctly.

`rawSubject` option disables quoted-printable encoding for the subject.

### Allowed Mail Formats

A single address `[email protected]` with the name `NAME` can be encoded in the
Expand Down
4 changes: 3 additions & 1 deletion config/mail/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface SendConfig {
*/
internalTag?: string | symbol;
headers?: Headers;
rawSubject?: boolean;
}

export interface ResolvedSendConfig {
Expand Down Expand Up @@ -76,6 +77,7 @@ export function resolveSendConfig(config: SendConfig): ResolvedSendConfig {
attachments,
internalTag,
headers,
rawSubject,
} = config;

return {
Expand All @@ -91,7 +93,7 @@ export function resolveSendConfig(config: SendConfig): ResolvedSendConfig {
}),
replyTo: replyTo ? parseSingleEmail(replyTo) : undefined,
inReplyTo,
subject: quotedPrintableEncodeInline(subject),
subject: rawSubject ? subject : quotedPrintableEncodeInline(subject),
attachments: attachments
? attachments.map((attachment) => resolveAttachment(attachment))
: [],
Expand Down