Skip to content

Commit 96837e8

Browse files
committed
docs(auth): document explicit auth modes and oauth2 test env 📜
- Add oauth2 env placeholders and integration test toggle in env example - Document password auth type in README config and test export examples - Update usage guide with explicit password or oauth2 auth configuration
1 parent 584b1d3 commit 96837e8

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Ethereal SMTP credentials for integration tests.
12
ETHEREAL_USER=your-ethereal-username
23
ETHEREAL_PASS=your-ethereal-password
4+
5+
# OAuth2 integration token (optional).
6+
SMTP_OAUTH2_ACCESS_TOKEN=your-oauth2-access-token
7+
8+
# Integration test flags.
39
RUN_SECURE_SMTP_TEST=false
10+
RUN_OAUTH2_SMTP_TEST=false

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const transporter = mailer.transporter({
3737
port: 587,
3838
secure: false,
3939
auth: {
40+
type: 'password',
4041
user: 'user@domain.com',
4142
pass: 'password'
4243
}
@@ -76,6 +77,10 @@ deno task test
7677
export ETHEREAL_USER=your-ethereal-username
7778
export ETHEREAL_PASS=your-ethereal-password
7879

80+
# Optional: run OAuth2 integration test too.
81+
export SMTP_OAUTH2_ACCESS_TOKEN=your-oauth2-access-token
82+
export RUN_OAUTH2_SMTP_TEST=true
83+
7984
# Optional: run secure TLS (port 465) integration test too.
8085
export RUN_SECURE_SMTP_TEST=true
8186

USAGE.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const config = {
5151
port: 587,
5252
secure: false,
5353
auth: {
54+
type: 'password',
5455
user: 'your-email@gmail.com',
5556
pass: 'your-app-password'
5657
}
@@ -59,15 +60,26 @@ const config = {
5960

6061
### Authentication
6162

62-
Deno Mailer supports LOGIN and PLAIN authentication methods.
63+
Deno Mailer supports two explicit authentication modes:
64+
65+
- `type: 'password'` using LOGIN with PLAIN fallback
66+
- `type: 'oauth2'` using XOAUTH2 bearer token
6367

6468
```ts
65-
// Basic authentication object.
69+
// Password authentication object.
6670
auth: {
71+
type: 'password',
6772
user: 'username',
6873
pass: 'password'
6974
}
7075

76+
// OAuth2 authentication object.
77+
auth: {
78+
type: 'oauth2',
79+
user: 'username',
80+
accessToken: 'access-token-value'
81+
}
82+
7183
// For local SMTP without auth, omit `auth`.
7284
```
7385

@@ -368,13 +380,15 @@ await transporter.send({
368380

369381
### Configuration Options
370382

371-
| Option | Type | Required | Description | Example |
372-
| ----------- | ------- | -------- | -------------------- | --------------------------- |
373-
| `host` | string | yes | SMTP server hostname | `'smtp.gmail.com'` |
374-
| `port` | number | yes | SMTP server port | `587`, `465`, `25` |
375-
| `secure` | boolean | no | Use TLS connection | `true` (465), `false` (587) |
376-
| `auth.user` | string | no | SMTP username | `'user@example.com'` |
377-
| `auth.pass` | string | no | SMTP password | `'your-password'` |
383+
| Option | Type | Required | Description | Example |
384+
| ------------------ | ------- | -------- | -------------------- | --------------------------- |
385+
| `host` | string | yes | SMTP server hostname | `'smtp.gmail.com'` |
386+
| `port` | number | yes | SMTP server port | `587`, `465`, `25` |
387+
| `secure` | boolean | no | Use TLS connection | `true` (465), `false` (587) |
388+
| `auth.type` | string | no | Auth mode | `'password'`, `'oauth2'` |
389+
| `auth.user` | string | no | SMTP username | `'user@example.com'` |
390+
| `auth.pass` | string | no | SMTP password | `'your-password'` |
391+
| `auth.accessToken` | string | no | OAuth2 bearer token | `'ya29.a0...'` |
378392

379393
### Message Properties
380394

@@ -423,6 +437,7 @@ const transporter = mailer.transporter({
423437
port: 587,
424438
secure: false,
425439
auth: {
440+
type: 'password',
426441
user: 'your-email@gmail.com',
427442
pass: 'your-app-password'
428443
}
@@ -438,6 +453,7 @@ const transporter = mailer.transporter({
438453
port: 587,
439454
secure: false,
440455
auth: {
456+
type: 'password',
441457
user: 'your-email@outlook.com',
442458
pass: 'your-password'
443459
}
@@ -453,6 +469,7 @@ const transporter = mailer.transporter({
453469
port: 587,
454470
secure: false,
455471
auth: {
472+
type: 'password',
456473
user: 'noreply@yourcompany.com',
457474
pass: 'your-password'
458475
}

0 commit comments

Comments
 (0)