EC-Nordbund / denomailer

A SMTP-Client implementation for deno (to send mails!)
https://deno.land/x/denomailer
MIT License
52 stars 17 forks source link

Feature request : Add an error when the target email does not exist #6

Closed louiszgn closed 2 years ago

louiszgn commented 2 years ago

Currently when a Domain doesn't exist, this error is returned : Error: 450: 4.1.2 <XXXXX@XXXXX.XXX>: Recipient address rejected: Domain not found

But if the email has an existing domain, even if this email does not exist, nothing happen.

Why not also return a similar error? For example : Error: 550: 5.1.1 <XXXXX@gmail.com>: Recipient address rejected: Email not found

mathe42 commented 2 years ago

That is not possible the 450 Error is something provided by the smtp server (it can't resolve the DNS or didn't found a MX entry etc) and the smtp server doesn't know if xxx@gmail.com exits.

louiszgn commented 2 years ago

In the return email indicating that this email does not exist, this error is displayed : Diagnostic-Code: smtp; 550 5.1.1 <XXXX@gmail.com>: Recipient address rejected: User unknown

We can see here that the code 550 exist for smtp

mathe42 commented 2 years ago

Yes that is expected. But at mail creation this is not known.

louiszgn commented 2 years ago

Okay I see. Do you know how we can get this info then?

mathe42 commented 2 years ago

I found https://github.com/reacherhq/check-if-email-exists that actually can do it. (is rust based I never written a single line rust so I will not look deeply into it)

The question is what should happen if in to we have 100 mails and 1 is not vaild. I don't think the complete mail should be garbage. Or should it?

My idea would be to add a constructor option "mail filter" where you can provide a callback that runs for each mail in to, cc and bcc and returns 'OK', 'REMOVE' or 'FAIL' depending on if it should be removed or if the complete mail sending should be prevented. (maybe also allow Promise<'OK'|'REMOVE'|'FAIL'> as return type) that would allow users to add:

  1. Email checks
  2. Is disposable mail
  3. Database lookups
  4. ...
louiszgn commented 2 years ago

Hello 👋 I was trying to retrieve the responses from the smtp server when I noticed that the one from the dependency does not match the one I get. Would you know why?

The response I get : image

The response the dependency get :

┌───────┬────────────────────────────────┐
│ (idx) │ Values                         │
├───────┼────────────────────────────────┤
│     0 │ "RCPT"                         │
│     1 │ "TO:"                          │
│     2 │ "<knkldfnlkmdsnqkj@gmail.com>" │
└───────┴────────────────────────────────┘
250 2.1.5 Ok
mathe42 commented 2 years ago

Not shure. How do you created the first response?

louiszgn commented 2 years ago

I followed these instructions but with gmail.com

mathe42 commented 2 years ago

The second one (with denomailer) was with the same SMTP server?

mathe42 commented 2 years ago

I'm not sure...

I basicly want to change the behavior so that a wrong E-Mail don't prevent sending so I will change that handling in the future.

(some links for me) https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml http://cloud.siegnetz.de/services/smtp-status-codes/ https://en.wikipedia.org/wiki/List_of_SMTP_server_return_codes

suchislife801 commented 2 years ago

Just to clarify.

Is it possible to check if destination email exists if your email account belongs to the same service as the destination email.

Example in which is possible:

You log in with you gmail account, to a gmail server and try to send mail to a gmail account that does not exist.

Example in which is not possible:

You log in with you gmail account, to a gmail server and try to send to mail to a yahoo account that does not exist. There is no way for a gmail server to check its own database for a yahoo email account. As a result, it will dispatch the email only to have yahoo bounce the message back as undeliverable.

You may now close this issue as there is no work around. It's not a problem. You've just misunderstood its workflow.