How to send an emailing through a website made with code to an email address?

I need help with emailing through a website. I an not doing this for school this is my own project that I am working on and I’m having some trouble with using database and what not

Here is the video
https://www.youtube.com/watch?v=IxziwuuaS3c

Setup your own to test would be best

I am using visual studio code, JavaScript and CSS, no html, next.js and node.js (I think) I change the files from js to jsx

Here is my code:

“use client”;

import Email from ’emailjs-com’;

import Link from ‘next/link’;

import { useEffect } from ‘react’; // Import useEffect hook

import ‘../emailUs/formEmail.css’;

const EmailUs = () => {

useEffect(() => {

// Wrap the code that accesses the document object inside the useEffect hook

const form = document.querySelector("form");




// Get form fields inside the function

const fullname = document.getElementsByName("name");

const email = document.getElementsByName("email");

const phone = document.getElementsByName("phone");

const subject = document.getElementsByName("subject");

const message = document.getElementsByName("message");




function sendEmail() {




  // Compose email body

  const bodyMessage = `Full Name: ${fullname.value}<br>Email: ${email.value}<br>Phone: ${phone.value}<br>Subject: ${subject.value}<br>Message: ${message.value}`;




  // Send email using Email.js

  // This code will only run in the browser environment

  Email.send({

    Host: "smtp.elasticemail.com",

    Username: "[email protected]",

    Password: "",

    To: '[email protected]',

    From: "[email protected]",

    Subject: subject.value,

    Body: bodyMessage

  }).then(

    message => alert(message)

  );

}




// Add event listener inside the useEffect hook

// This code will only run in the browser environment

form.addEventListener("submit", (e) => {

  e.preventDefault();

  sendEmail();

});




// Clean up the event listener when the component unmounts

return () => {

  // This code will only run in the browser environment

  form.removeEventListener("submit", (e) => {

    e.preventDefault();

    sendEmail();

  });

};

}, []);

return (

<div>

  {/* Header */}

  <header>

    <div className="logo">Logo</div>

    <div className="header-links">

      <Link href="/email-us">Email Us</Link>

      <Link href="/login">Login</Link>

      <Link href="/sign-in">Sign In</Link>

    </div>

  </header>




  {/* Navigation */}

  <nav style={{}}>

      <ul>

        <li><Link href="/">Home</Link></li>

        <li><Link href="/aboutUs">About Us</Link></li>

        <li><Link href="/buy">Buy</Link></li>

        <li><Link href="/sell">Sell</Link></li>

        <li><Link href="/featured-listings">Featured Listings</Link></li>

        <li>

          <a> Area </a>

          <ul className="dropdown">

            <li /*style={{paddingLeft: '20px'}}*/><Link href="/area/1">A1</Link></li>

            <li><Link href="/area/2">A2</Link></li>

          </ul>

        </li>

        <li><Link href="/propertySearch">Property Search</Link></li>

        <li><Link href="/blog">Blog</Link></li>

        <li><Link href="/contactUs">Contact Us</Link></li>

      </ul>

    </nav>




    {/* Main Content */}

   

        <main style={{paddingTop: '100px'}}>

            <div className="formForEmail" /*style={{paddingTop: '100px'}}*/>

                <form className='formForEmailDesign'>

                    <h3 className="formh3">GET IN TOUCH</h3>

                    <input className='forminputformtextarea' type="text" name="name" placeholder='Your name' required/>

                    <input className='forminputformtextarea' type="email" name="email" placeholder='Email id' required/>

                    <input className='forminputformtextarea' type="text" name="phone" placeholder='Phone no' required/>

                    <input className='forminputformtextarea' type="text" name="subject" placeholder='Subject' required/>

                    <textarea className='forminputformtextarea' name="message" row="4" placeholder='How can we help you?' required/>

                    <button className='formbutton' type="submit">Send Email</button>

                </form>

            </div>

            <script src='https://smtpjs.com/v3/smtp.js'></script>

            <script src='script.js'></script>

        </main>

        {/* Footer */}

            <footer>

                {/* Add footer content here */}

            </footer>

</div>

);

};

export default EmailUs;

formEmail.css:

/* Email Form*/

.formForEmail{

width: 100%;

height: 100%;

display: flex;

align-items: center;

justify-content: center;

}

.formForEmailDesign{

background: #bb9c65;

display: flex;

flex-direction: column;

padding: 10px 20px;

width: 90%;

max-width: 600px;

border-radius: 10px;

color: #0f0f0f;

}

.formh3{

color: #555;

font-weight: 800;

margin-bottom: 20px;

}

.forminputformtextarea{

border: 0;

margin: 10px 0;

padding: 20px;

outline: none;

background: #f5f5f5;

font-size: 16px;

}

.formbutton{

padding: 15px;

background: #ff5361;

color: #fff;

font-size: 18px;

border: 0;

outline: none;

cursor: pointer;

width: 150px;

margin: 20px auto 0;

border-radius: 30px;

}

I try to follow the video and add other things like useEffect
Some code
And explanation on what to do.

New contributor

Huzaifa Hafeez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật