Skip to content

send email failed by office365 smtp #73

@carlos411

Description

@carlos411

Describe the bug

send email failed by office365 smtp

To Reproduce

My Code:

import { SMTPClient } from "https://deno.land/x/[email protected]/mod.ts"

const client = new SMTPClient({
  debug: {
    log: true
  },
  connection: {
    hostname: "smtp.office365.com",
    port: 587,
    tls: false,
    auth: {
      username: "my_email",
      password: "my_password"
    }
  }
});

await client.send({
  from: "ServiceName <my_email>",
  to: "ReceiverName <other_email>",
  subject: "my subject test",
  html: "<h1>this is heading</h1>"
});

await client.close();

Expected behavior

Send email normally.

Logs

deno --version output:

deno 1.33.4 (release, x86_64-apple-darwin)
v8 11.4.183.2
typescript 5.0.4

debug output log

used resolved config
.debug
┌───────────────┬────────┐
│ (idx)         │ Values │
├───────────────┼────────┤
│ log           │ true   │
│ allowUnsecure │ false  │
│ encodeLB      │ false  │
│ noStartTLS    │ false  │
└───────────────┴────────┘
.connection
┌──────────┬───────────────────────────────────────────────────────────────┐
│ (idx)    │ Values                                                        │
├──────────┼───────────────────────────────────────────────────────────────┤
│ hostname │ "smtp.office365.com"                                          │
│ port     │ 587                                                           │
│ tls      │ false                                                         │
│ auth     │ '{"username":"my_email","password":"my_password"}' │
└──────────┴───────────────────────────────────────────────────────────────┘
.pool
undefined
220 TYWPR01CA0019.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 23 May 2023 15:35:07 +0000
┌───────┬──────────────────────┐
│ (idx) │ Values               │
├───────┼──────────────────────┤
│     0 │ "EHLO"               │
│     1 │ "smtp.office365.com" │
└───────┴──────────────────────┘
250-TYWPR01CA0019.outlook.office365.com Hello [219.68.233.17]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
┌───────┬────────────┐
│ (idx) │ Values     │
├───────┼────────────┤
│     0 │ "STARTTLS" │
└───────┴────────────┘
error: Uncaught (in promise) Error: invalid cmd
      throw new Error(`invalid cmd`);
            ^
    at SMTPConnection.assertCode (https://deno.land/x/[email protected]/client/basic/connection.ts:76:13)
    at SMTPConnection.writeCmdAndAssert (https://deno.land/x/[email protected]/client/basic/connection.ts:132:10)
    at eventLoopTick (ext:core/01_core.js:181:11)

Could you help to fix it? Thanks a lot!
On the other hand, If I use Node.js package NODEMAILER under Node.js environment, it can send email normally.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions