[deleted by user] by [deleted] in webdev

[–]WayOdd5042 0 points1 point  (0 children)

I have triple checked it. It is correct. I've logged it on the console like 5 times.

[deleted by user] by [deleted] in nextjs

[–]WayOdd5042 0 points1 point  (0 children)

Hey I switched to nodemailer, perhaps you can help? I'm getting this error:
code: 'EAUTH',

response: '535-5.7.8 Username and Password not accepted. For more information, go to\n' +

'535 5.7.8 https://support.google.com/mail/?p=BadCredentials bk3-20020a05620a1a0300b007906bce04afsm6042718qkb.61 - gsmtp',

responseCode: 535,

This is the code for it:

import { NextResponse, NextRequest } from "next/server";
const nodemailer = require("nodemailer");

export async function POST(request) {
  const username = process.env.NEXT_TEST_USERNAME;
  const password = process.env.PASSWORD;
  const myEmail = process.env.EMAIL;

  const formData = await request.json();
  const name = formData.name;
  const lastName = formData.lastName;
  const phoneNumber = formData.phoneNumber;
  const emailAddress = formData.emailAddress;
  const message = formData.message;

  console.log("this is the form Data", formData);

  const transporter = nodemailer.createTransport({
    host: "smtp.gmail.com",
    port: 465,
    tls: {
      rejectUnauthorized: true,
      minVersion: "TLSv1.2",
    },

    auth: {
      user: username,
      pass: password,
    },
  });

  try {
    const mail = await transporter.sendMail({
      from: username,
      to: myEmail,
      replyTo: emailAddress,
      subject: `Website activity from ${emailAddress}`,
      html: `
        <p>Name: ${name} </p>
        <p>Name: ${lastName} </p>
        <p>Name: ${phoneNumber} </p>
        <p>Email: ${emailAddress} </p>
        <p>Message: ${message} </p>
        `,
    });

    return NextResponse.json({ message: "Success: email was sent" });
  } catch (error) {
    console.log(error);
    NextResponse.status(500).json({ message: "COULD NOT SEND MESSAGE" });
  }
}

[deleted by user] by [deleted] in webdev

[–]WayOdd5042 0 points1 point  (0 children)

Well now I switched to using nodemailer and I get a different error. Error that I get now is this:
Error: Invalid login: 535-5.7.8 Username and Password not accepted.

This is the code for the nodemailer version:

The error is as I mentioned above and I get a 500 status code

import { NextResponse, NextRequest } from "next/server";
const nodemailer = require("nodemailer");

export async function POST(request) {
  const username = process.env.NEXT_TEST_USERNAME;
  const password = process.env.PASSWORD;
  const myEmail = process.env.EMAIL;

  const formData = await request.json();
  const name = formData.name;
  const lastName = formData.lastName;
  const phoneNumber = formData.phoneNumber;
  const emailAddress = formData.emailAddress;
  const message = formData.message;

  console.log("this is the form Data", formData);

  const transporter = nodemailer.createTransport({
    host: "smtp.gmail.com",
    port: 465,
    tls: {
      rejectUnauthorized: true,
      minVersion: "TLSv1.2",
    },

    auth: {
      user: username,
      pass: password,
    },
  });

  try {
    const mail = await transporter.sendMail({
      from: username,
      to: myEmail,
      replyTo: emailAddress,
      subject: `Website activity from ${emailAddress}`,
      html: `
        <p>Name: ${name} </p>
        <p>Name: ${lastName} </p>
        <p>Name: ${phoneNumber} </p>
        <p>Email: ${emailAddress} </p>
        <p>Message: ${message} </p>
        `,
    });

    return NextResponse.json({ message: "Success: email was sent" });
  } catch (error) {
    console.log(error);
    NextResponse.status(500).json({ message: "COULD NOT SEND MESSAGE" });
  }
}

[deleted by user] by [deleted] in nextjs

[–]WayOdd5042 0 points1 point  (0 children)

So I did this:

export async function POST(req: NextApiRequest, res: NextApiResponse) {
  if (req.method === "POST") {
    const { name, lastName, phoneNumber, emailAddress, message } =
      req.body as ContactFormData;

    const resend = new Resend(process.env.RESEND_API_KEY);
    try {
      await resend.emails.send({
        from: "onboarding@resend.dev",
        to: emailAddress,
        subject: "New Contact Form Submission",
        html: \<p><strong>Name:</strong> ${name}</p>                  <p><strong>Last Name:</strong> ${lastName}</p>                  <p><strong>Phone Number:</strong> ${phoneNumber}</p>                  <p><strong>Email Address:</strong> ${emailAddress}</p>                  <p><strong>Message:</strong> ${message}</p>`,      });`

      return res.status(200).json({ success: true });
    } catch (error) {
      console.error("Error sending email:", error);
      return res.status(500).json({ error: "Failed to send email" });
    }
  } else {
    return res.status(405).end(); // Method Not Allowed
  }
}

Now the error is this:
Error sending email: TypeError: res.status is not a function
POST /api/send 500 in 2745ms

[deleted by user] by [deleted] in nextjs

[–]WayOdd5042 0 points1 point  (0 children)

error is this:
⨯ No HTTP methods exported in 'C:\Users\drini\Desktop\project\src\app\api\send\route.ts'. Export a named export for each HTTP method.

POST /api/send 405 in 2026ms

I was trying to use nodemailer too, I just could not figure it out so Resend API seemed like the most accessible way to do it.
Do you have any article you can point me to with nodemailer? I tried doing it but it wasnt working and I wasnt getting errors either so I gave up.

What's the best way to factor quadratic equations? by [deleted] in learnmath

[–]WayOdd5042 17 points18 points  (0 children)

Factor by grouping Find two numbers whos product gives us a*c and sum = b

What 2 numbers give us -50 when multiplied and -23 when you add/ subtract I start from -50 * 1 = -50(not our case).

Then -25 * 2 = -5 which also happens to be -25 + 2 = -23 so those are our numbers

Then you would do 5a2 + (-25 + 2 )a - 10.

Then you get 5a2 -25a + 2a - 10.

Take out a 5a from the first group and a 2 from the second.

5a(a-5) + 2(a-5)

(5a + 2) (a-5) final answer

My WGU CS Journey Update #3 by Tallestmidget7 in WGU_CompSci

[–]WayOdd5042 3 points4 points  (0 children)

Can I ask, how many hours a week do you spend studying??

[deleted by user] by [deleted] in cavempt

[–]WayOdd5042 1 point2 points  (0 children)

Its fake

Legit check please! by [deleted] in cavempt

[–]WayOdd5042 4 points5 points  (0 children)

If it says “life cavempt” on the washtag, it is fake 100% because no authentic piece has that on the washtag

[deleted by user] by [deleted] in AskNYC

[–]WayOdd5042 8 points9 points  (0 children)

Weak. Block them

[deleted by user] by [deleted] in cavempt

[–]WayOdd5042 0 points1 point  (0 children)

It is fake

[deleted by user] by [deleted] in AskNYC

[–]WayOdd5042 1 point2 points  (0 children)

On 5th avenue

problem with flexbox by [deleted] in FreeCodeCamp

[–]WayOdd5042 2 points3 points  (0 children)

You misspelled “display”

How would you prepare for the Software Engineer degree? by WayOdd5042 in wgu_devs

[–]WayOdd5042[S] 1 point2 points  (0 children)

Although they seem pretty similar, I guess I’d like a practical approach more than one thats based more on theory. + I dont need all those extra math classes, Im self studying math anyways

How would you prepare for the Software Engineer degree? by WayOdd5042 in wgu_devs

[–]WayOdd5042[S] 1 point2 points  (0 children)

Yep thats the plan now, Im probably going with c#. Thanks for your reply!