sousadiego11
sousadiego11β€’14mo ago

Help using DenoMailer

i'm trying to use it but i get Deno is not defined when i try to send the email, any tips? how would you approach it?
import { SMTPClient } from "https://deno.land/x/denomailer@1.6.0/mod.ts";
import { IRelatoForm } from "../../types/index.ts";


export async function send(form: IRelatoForm) {
const client = new SMTPClient({
connection: {
hostname: "smtp.gmail.com",
port: 465,
tls: true,
auth: {
username: "test.test@gmail.com",
password: "test",
},
},
});
await client.send({
from: "test.test@gmail.com",
to: "test@test.com.br",
subject: "TESTE FRESH MAIL",
content: "conteudo teste",
html: `<p>${JSON.stringify(form)}</p>`,
});

await client.close();
}
import { SMTPClient } from "https://deno.land/x/denomailer@1.6.0/mod.ts";
import { IRelatoForm } from "../../types/index.ts";


export async function send(form: IRelatoForm) {
const client = new SMTPClient({
connection: {
hostname: "smtp.gmail.com",
port: 465,
tls: true,
auth: {
username: "test.test@gmail.com",
password: "test",
},
},
});
await client.send({
from: "test.test@gmail.com",
to: "test@test.com.br",
subject: "TESTE FRESH MAIL",
content: "conteudo teste",
html: `<p>${JSON.stringify(form)}</p>`,
});

await client.close();
}
No description
No description
8 Replies
Deno AI Helper
Deno AI Helperβ€’14mo ago
I'm sorry, but the documentation does not provide information about DenoMailer. Therefore, I can't provide a specific solution to your problem. However, I can suggest some general debugging steps: 1. Make sure you're running your script with the correct permissions. Deno is secure by default, so network access (like sending an email) is not allowed unless you explicitly allow it. You can do this by adding the --allow-net flag when you run your script. 2. Check the version of Deno you're using. Some modules may not work correctly with older versions of Deno. You can check your Deno version by running deno --version in your terminal. 3. Make sure the module you're importing is compatible with your Deno version. You can usually find this information in the module's documentation or repository. 4. If you're seeing a "Deno is not defined" error, it might be because you're trying to use Deno-specific APIs in a context where they're not available, like a web worker or a frontend script. Make sure you're running your Deno code in a Deno runtime. Remember, these are general tips and might not solve your specific problem since they are not based on the documentation's information about DenoMailer.
Kojo.gg
Kojo.ggβ€’14mo ago
You can’t run Deno in the browser Also, you can’t run any email service on Deno Deploy due to past users abuse that led to emails port restrictions. Use some API like Postmark, or SendGrid to send emails.
raunioroo
rauniorooβ€’14mo ago
^ beat me to it :) i'm not familiar with preact which you seem to be using, but some of these frameworks can get one easily confused where a given code is going to be run, client server or both (SSR vs CSR). that can be particularly worrying in this case, as mail server credentials are embedded in the code
sousadiego11
sousadiego11OPβ€’14mo ago
Happy to say the issue is solved. I was realy trying to run at the browser, was confused with it. also i'm not using with deploy, so its gonna work, thanks!
Kojo.gg
Kojo.ggβ€’14mo ago
Good, mark it as solved please πŸ‘
sousadiego11
sousadiego11OPβ€’14mo ago
not sure how i do it..
Kojo.gg
Kojo.ggβ€’14mo ago
You modify your initial post, I see that you already have a tag β€œDeno.*API” and add the Message tag with β€œSolved βœ…β€.
sousadiego11
sousadiego11OPβ€’14mo ago
alright, done!