invertase / dart_edge

Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
https://docs.dartedge.dev
Apache License 2.0
324 stars 23 forks source link

Send an email inside a Edge function #45

Open nuno84 opened 1 year ago

nuno84 commented 1 year ago

Hi, I can send an email using SMTP in Typescript.

import { SMTPClient } from "https://deno.land/x/denomailer/mod.ts";
....
  const smtp = new SMTPClient({
    connection: {
      hostname: Deno.env.get('_SMTP_HOSTNAME')!,
      port: Number(Deno.env.get('_SMTP_PORT')!),
      tls: true,
      auth: {
        username: Deno.env.get('_SMTP_USERNAME')!,
        password: Deno.env.get('_SMTP_PASSWORD')!,
      },
    },
  });
...
await smtp.send({ ....})

However I would prefer to use Dart on the Edge functions. I tried to use the mailer library but it doesn't work. issue What is the best way to achieve this? I can't seem to find a solution in the web, which is weird because I thought it would be a usual feature. Am I overlooking something? Thank you for any tips

MichealReed commented 1 year ago

Use something like mailgun or another actual SMTP API. Using cloud function ips for email sending is a good way to get flagged as spam. Probably many other reasons not to do this with a serverless function too.

nuno84 commented 1 year ago

Hi Machael, But the question is why is it possible in Typescript but there is no alternative in Dart? After all, Dart is converted to JS as well. I can't figure out a reason for it. You are saying that it is bad practice to use in Typescript also, is that it? Thank you for your time.

MichealReed commented 1 year ago

Yes, bad practice in both. If supabase hasn't blocked, they probably will at some point. As far as being possible in JS vs Dart, it's all about the libraries. JS/Typescript typically has more than dart, but dart is catching up.

henry2man commented 1 year ago

Use something like mailgun or another actual SMTP API. Using cloud function ips for email sending is a good way to get flagged as spam. Probably many other reasons not to do this with a serverless function too.

@nuno84 Maybe we should accept this as the proper solution...