I love these new edge functions but I've already e...
# help
a
I love these new edge functions but I've already encountered a problem when I wanted to test smtp connections 🥲
n
Hello @Albert [tox/cis]! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
a
I've tried debugging the function but all I get is a timeout with the error
TimedOut: Connection timed out (os error 110) at async Object.connect (deno:ext/net/01_net.js:323:17) at async SmtpClient.connect (file:///src/main.ts:721:22) at async Server. (file:///src/main.ts:838:5) at async Server.#respond (file:///src/main.ts:111:24)
s
can you share the code snippet
n
Albert [toxcis] (2022-04-01)
a
Sure
Copy code
js
import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
import { SmtpClient } from "https://deno.land/x/smtp@v0.7.0/mod.ts";

serve(async (req) => {
  console.log('creating connection');
  const client = new SmtpClient();
  await client.connect({
    hostname: "mymailserver",
    port: 465,
    username: "myemail",
    password: "mypassword"
  });
  console.log('sending e-mail');
  await client.send({
    from: "myemail",
    to: "myprivateemail",
    subject: "Mail Title",
    content: "Mail Content, maybe HTML"
  });
  console.log('sent e-mail');
  
  await client.close();
  return new Response(
    JSON.stringify({'hello': 'çiao'}),
    { headers: { "Content-Type": "application/json" } },
  );
});
s
who is the service provider?
gmail? sendgrid?
a
I have a server at djangoeurope which I use
My own so to speak
It worked with firebase but it doesn't work with supabase 😭
s
okay, let me check
Copy code
await client.connectTLS({
  hostname: "smtp.gmail.com",
  port: 465,
  username: "your username",
  password: "your password",
});
connectTLS
a
I've tried TLS as well but that gives me the same timeout
g
From the guide. Deno Deploy limitations Deno does not support outgoing connections to ports 25, 465, and 587.
a
Ah hahaha that's a helpful hint 😁
So, ist there a possibility to exploit SMTP over TLS without using deno?
g
I’m not sure what is up yet, but the first function I’ve been waiting to move from Firebase is a pdf generator that e-mails result…..
a
I've been wanting to use a similar functionality 😄
g
I opened an issue: https://github.com/supabase/supabase/issues/6255 But I'm winging it a bit on the meaning of the restriction as it is clear Deno supports smtp type operations. Unfortunately I upgraded my sveltekit dev environment with latest modules and now I'm dead in the water on some svelte ssr issue so working on solving that first before testing functions more...
a
Thanks for submitting an issue. It's somewhat contradictory. On one hand, they don't support outgoing ports but they do support an smtp library.
s
its supported with deno, deno deploy is their platform there they have blocked such ports
g
Well, I luck out... My email service I've been using for awhile ( Sendinblue ) has a full API, so don't need SMTP. Took 5 minutes to use fetch in deno to send an email. Says it handles attachments too, we will see how easy that is. Pretty reasonable monthy free plan for testing and price seemed good for production when I looked around a year ago.