Coder Social home page Coder Social logo

deno-smtp's People

Contributors

0xtlt avatar bauh0lz avatar bookshell527 avatar cbioley avatar manyuanrong avatar schotsl avatar soremwar avatar timonson avatar timreichen avatar yrm006 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

deno-smtp's Issues

Coudn't understand how to use reading Readme file

Dear , author.

First of all, I want to thank you for last upgrading of your package.

Could I ask you to provide a sample example of how to use correctly your package with gmail service, because I ve got an error like:
Socket Error 10061 Connection Refused.

Feel free to close this issue.

README

Hello, first I would like to thanks you for this package for deno.

Works nicely, but I have noticed that part of the read me is not correct. Specifically, the part explaining use case with gmail. Firstly, there is a typo, in line: --hostname: "smtp.gamil.com",--. Secondly, interface ConnectConfig doesnt have a "tls" key (parameter).

Suggestions for the future: I noticed, when sending, I can only send email to only one person. Would be nice to implement possibility to send to multiple people by giving an array.

Again, thank you. Eventhough there is still a way to upgade, it is still a good work.

Error while using microsoft email for smtp

Working fine with my Gmail credentials.
I used the following credentials:
For more port info click here

await client.connectTLS({
        hostname: "smtp.office365.com",
        port: 587,
        username: "***@mydomain.com",
        password: "*********"
});

Error:

DenoStdInternalError: bufio: caught error from `readSlice()` without `partial` property
    at assert (https://deno.land/[email protected]/_util/assert.ts:13:11)
    at BufReader.readLine (https://deno.land/[email protected]/io/bufio.ts:254:7)
    at async TextProtoReader.readLineSlice (https://deno.land/[email protected]/textproto/mod.ts:131:17)
    at async TextProtoReader.readLine (https://deno.land/[email protected]/textproto/mod.ts:33:15)
    at async SmtpClient.readCmd (https://deno.land/x/[email protected]/smtp.ts:151:20)
    at async SmtpClient._connect (https://deno.land/x/[email protected]/smtp.ts:118:21)
    at async SmtpClient.connectTLS (https://deno.land/x/[email protected]/smtp.ts:68:5)

Can not connect to gmail account

Hello, I'm trying to connect my gmail account with gmail smtp but i get this error:

error: Uncaught ConnectionRefused: No connection could be made because the target machine actively refused it. (os error 10061)
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async Object.connectTls ($deno$/tls.ts:20:15)
    at async SmtpClient.connectTLS (https://deno.land/x/smtp/smtp.ts:36:18)`
Here's the code I use (similar to docs).
import { SmtpClient } from "https://deno.land/x/smtp/mod.ts";

const client = new SmtpClient();

await client.connectTLS({
  host: "smtp.gmail.com",
  port: 465,
  username: "my gmail",
  password: "my password",
});

Improve tests

If I'm not mistaken, currently just cover one specific setup: Connection with TLS (as read from ENV) and an email with both text and html content.

  • Test non TLS connection
  • Test sending plain text email only

Error for Deno v1.4.0

Like the other package when i updated it to Deno v1.4.0, i got error like this

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import {
^
    at https://deno.land/x/[email protected]/smtp.ts:2:1

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
    ConnectConfig,
    ~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/mod.ts:2:5

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
    ConnectConfigWithAuthentication,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/mod.ts:3:5

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
    SendConfig,
    ~~~~~~~~~~
    at https://deno.land/x/[email protected]/mod.ts:4:5

Please fix this by adding Import type and Export type for interface or any other type

Cannot use authentification

Hello,

I got this error when trying to connect.

error: TS2345 [ERROR]: Argument of type
'{ hostname: string; port: number; username: string; password: string; }' 
is not assignable to parameter of type 'ConnectConfig'.

Object literal may only specify known properties, and 'username' does not exist in type 'ConnectConfig'.

I'm using this version:

import { SmtpClient } from "https://deno.land/x/smtp@master/mod.ts";

as I saw that some fixed where added. I think what we're missing is the export of the connect config with authentification.

[Feature Request] STARTTLS

How hard would it be to implement support for upgrading unencrypted connections via the STARTTLS command? Deno seems to include an new unstable API Deno.startTls which in theory should support upgrading connections.

Does not work with Deno v1.2.x

Hi!

Like many other third-party libraries, this one also does not yet work with Deno v1.2.x.

I get two errors when I want to run the file with the basic Gmail setup:

error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/[email protected]/path/win32.ts:911:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/[email protected]/path/posix.ts:433:18

It seems as if [email protected] causes the problem.

Maybe you could update the std library to the version used in Deno v.1.2.x ([email protected]) to fix the issue for people who want to use the latest versions of Deno?

Thank you very much!

How to Attach PDF?

Hello. First I wanted to say this library is great and working with the latest version of Deno 1.2.3.

I would like to know if you can post an example of how to attach PDF files to the email message using deno?

Thank you!

Content is empty due to missing blank line

If I use the example provided in the README to send an email to an Exchange server, the recipient receives an email with no contents. From a quick look at smtp.ts, this happens because there's no blank line before the content. Indeed, if I prefix config.content with an additional \r\n, the content comes through as expected.

Allow multiple recipients

From what I can tell, there is currently no way to send an email to multiple recipients (other than recreating the client from scratch and resending the email). API-wise, it would be nice to be able to provide a list of strings in to (cf. e.g. Python's smtplib.sendmail).

README example is not runnable

await client.connect({
host: "smtp.163.com", // ==> hostname: "smtp.163.com"
port: 25,
username: "username",
password: "password",
});

// ConnectConfig define
export interface ConnectConfig {
hostname: string;
port?: number;
username: string;
password: string;
}

Deno 1.13 error

Hi!

I use your example and get an error. It wasn't there in earlier versions...

Снимок экрана от 2021-08-15 12-06-47

Name or service not known

This example was running couple days before and now it gives me an error:

error: Uncaught Error: failed to lookup address information: Name or service not known
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async Object.connectTls ($deno$/tls.ts:20:15)
    at async SmtpClient.connectTLS (https://deno.land/x/smtp/smtp.ts:36:18)
    at async file:///home/pomatti/projects/bizi-infrastructure-code/deno-smtp/deno.ts:13:1
import { SmtpClient } from "https://deno.land/x/smtp/mod.ts";
import { ConnectConfigWithAuthentication } from "https://raw.githubusercontent.com/manyuanrong/deno-smtp/master/config.ts";

const client = new SmtpClient();

const params = <ConnectConfigWithAuthentication>{
  hostname: "smtp.google.com",
  port: 465,
  username: "[email protected]",
  password: "pa$$word"
}

await client.connectTLS(params);

await client.send({
  from: "[email protected]", // Your Email address
  to: "[email protected]", // Email address of the destination
  subject: "Mail Title",
  content: "Mail Content,maybe HTML",
});

await client.close();
$ deno --version
deno 1.0.3
v8 8.4.300
typescript 3.9.2

[Feature Request] Attachments

Hey! First of all, I think we can all agree that this library is great! Thanks for that mate!

One thing that would greatly improve the deno-smtp experience is being able to simply send attachments directly from the client.send method as an array. The attachments could be an object in the base64 + MIME type format, or something similar. I don't know how feasible it would be, but I think it could greatly enhance the deno-smtp experience.

Example:

await client.send({
    from: my_email,
    to: your_email,
    subject: "My title",
    content: "My content",
    attachments: [attachment_1, attachment_2, attachment_3]
  });

Thanks for reading!

ConnectionRefused: Connection refused (os error 111)

I deploy my project deno in https://dash.deno.com/ after using deno-smtp deploy failed but it work fine in develop environment (localhost).

ConnectionRefused: Connection refused (os error 111)
at async Object.connectTls (deno:ext/net/02_tls.js:37:42)
at async SmtpClient.connectTLS (https://deno.land/x/[email protected]/smtp.ts:35:22)
at async file:///src/core/service/mail/index.ts:5:1

here is the code snippet:

import { SmtpClient } from "https://deno.land/x/smtp/mod.ts";

interface informationMail{
    to: string,
    subject: string,
    text: string,
    html: string,
}
const client = new SmtpClient();

await client.connectTLS({
    hostname: "smtp.gmail.com",
    port: 465,
    username: Deno.env.get("EMAIL_DOMAIN"),
    password: Deno.env.get("EMAIL_APP_PASSWORD"),
});

export async function sendMail() {
    await client.send({
        from: Deno.env.get("EMAIL_DOMAIN"),
        to: "[email protected]", // list of receivers
        subject: "Hello ✔", // Subject line
        content: "Hello world?", // plain text body
    });

    return await client.close();
}

Does anyone know how to solve this problem ?
Thank you

Connection with Office365 account "InvalidData: received corrupt message"

Dear Author,
I'm trying to use your smtp module. But have some problems with connection to Microsoft smtp server.
Thank you for your any support in advance.

I receive message: "InvalidData: received corrupt message"
My configuration for office365 account:
EMAIL_FROM = [email protected] (mylogin and primary e-mail address as well on Office365 with Exchange on-line license)
EMAIL_PWD = my-password
EMAIL_TO = [email protected]
SMTP_SERVER = smtp.office365.com
SMTP_PORT = 587
TLS = true

I've checked with my gmail account - it works perfect. So I assume my code must be correct.
My configuration for gmail:
EMAIL_FROM = [email protected] (mylogin same as my primary e-mail address as well on gmail)
EMAIL_PWD = mypassword
EMAIL_TO = [email protected]
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=465
TLS=true

I've tested postfix as smtp relay to office365 account and sent e-mail from command line. Also works perfect.
So my generally smtp client can connect with office365 and send e-mail.
Any ideas ?


My code:
const client = new SmtpClient();
const { EMAIL_FROM, EMAIL_TO, SMTP_SERVER, SMTP_PORT, TLS, EMAIL_PWD } = config();

        const configConnection = {
            hostname: SMTP_SERVER,
            port: SMTP_PORT ? parseInt(SMTP_PORT) : undefined,
            username: EMAIL_FROM,
            password: EMAIL_PWD,
        };

        if (TLS) {
            await client.connectTLS(configConnection);
        } else {
            await client.connect(configConnection);
        }

        await client.send({
            from: EMAIL_FROM,
            to: EMAIL_TO,
            subject: topic,
            content: message,
        });

ConnectConfig username is not a know property

Hi,
today I had trouble with the username property of ConnectConfig.
I did not find any errors.

Argument of type '{ hostname: string; port: number; username: string; password: string; }' is not assignable to parameter of type 'ConnectConfig'. Object literal may only specify known properties, and 'username' does not exist in type 'ConnectConfig'.ts(2345)

The code:
export const client = new SmtpClient();

await client.connect({
hostname: MAIL_HOST,
port: Number(MAIL_PORT),
username: MAIL_USER,
password: MAIL_PASSWORD,
})

Please add a release tag with the updates

@manyuanrong Deno's registry doesn't allow commit or branch imports anymore (good decision in my opinion). So in order to import from deno.land/x you have to create a version tag/release so we can use it.

To register in the new repository, just follow the instructions in the https://deno.land/x/ landing page, from there on now the process should be automated.

For everyone else, in the meantime you can import from github directly (thanks ECMA for ES modules).

Latest commit as of 03/08/2020
https://raw.githubusercontent.com/manyuanrong/deno-smtp/bc38e10b8fd683f2bca350f2885f64553ab0ea51/mod.ts

import {
  SmtpClient
} from "https://raw.githubusercontent.com/manyuanrong/deno-smtp/bc38e10b8fd683f2bca350f2885f64553ab0ea51/mod.ts";

diacritical characters on subject field will not be interpreted correctly with icloud.com mail boxes

Hello Sir thanks for this contribution

Here is my workaround:

import * as base64 from "https://denopkg.com/chiefbiiko/base64/mod.ts";
import { SmtpClient } from "https://deno.land/x/smtp/mod.ts"

const diacritic = 'ça va?'
const b64: string = base64.fromUint8Array(new TextEncoder().encode(diacritic));

console.log(b64)
console.log(btoa(diacritic)) // will not output the same as previous

const to = '[email protected]'
const content = 'content with àccent'
const client = new SmtpClient({ content_encoding: "7bit" })
const subject = `=?utf-8?B?${b64}?=`

const connectConfig: any = { hostname: "in-v3.mailjet.com", port: 465, username: "", password: '' }
      
await client.connectTLS(connectConfig)
await client.send({ from: '[email protected]', to, subject, content })
await client.close()
console.log('finish')

💡 Note that I had to do the same thing (which is only documented in the official commands of smtp) for the node smtp-client package

Dead project? - I created a fork with a lot of new features

Hi as this project looks dead to me so I created a fork see https://deno.land/x/denomailer wich implements

  1. Attachments (#43 #56 )
  2. STARTTLS (thanks to #54 #47)
  3. cc, bcc and multiple recipients (#21)
  4. reply-to, and other fields
  5. html, content options with "auto" to generate a plain text for a html template (#52)
  6. alternative to html and content to use in some specific use cases (mimeContent option)

Note until I worked on this I was not familiar with the SMTP protocol so there might be some bugs in it!

Feel free to create issues at my fork and create PR!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.