Sending Emails Using Javascript & CSS via SMTP in a Contact Form

Currently fine-tuning a contact form and nearing completion. However, there seems to be a minor error preventing the form from submitting correctly. Expected behavior includes a pop-up confirmation box upon submission and successful message delivery. Yet, these actions are not occurring as intended. Any insights on what could possibly be causing this mismatch? Appreciate any assistance!

My goal, once the form functions smoothly, is to conceal a radio question within it as a honeypot mechanism.

Answer №1

Some potential issues that may arise include syntax errors, incorrect function calls, and the exposure of insecure passwords. Even if this code functions correctly, it poses a security risk.

function sendEmail() {
  Email.send({
    Host: "mail.siteediting.cc",
    Username: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="02716f76722f7667717642716b766767666b766b6c652c6161">[email protected]</a>",
    Password: "-1fpzJ8h*+H3",
    Port: "587",
    To: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="01686b76666e696d6f6e62417472642f72756073756c60686d2f626e6c">[email protected]</a>",
    From: document.getElementById("email").value,
    Subject: "S E Contact Form Message",
    Body: `Name: ${document.getElementById("name").value}<br><br>Email: ${document.getElementById("email").value}<br><br>Phone Number: ${document.getElementById("phone").value}<br><br>Message: ${document.getElementById("message").value}`
  }).then(
    message => alert('Message Sent!')
  );
}

It is important to note that exposing SMTP credentials in client-side JavaScript poses a significant security threat. It is advisable to utilize a server-side method for sending emails instead.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having success in FF and Chrome, but encountering issues in IE? What could be causing this disparity

My partner wrote a script, but he is currently offline so I am trying to troubleshoot the issue on my own. Here is the current code we are working with: function checkProgress(Progress) { // Retrieve progress status $.get('http://www.site.c ...

Step-by-step guide on setting up a click counter that securely stores data in a text file, even after the

Can anyone help me make this link actually function as intended? Right now it only runs the JavaScript code, but I would like it to run the code and redirect to a webpage. Additionally, I need the data to be saved to a text file. Please provide assistanc ...

What is the significance of the message "Legacy octal literals are prohibited in strict mode" in the context of ReactJS?

I am encountering an issue while attempting to iterate through these arrays where I keep receiving the error message "Legacy octal literals are not allowed in strict mode." const myList =[ { id: 01, title: 'FrontEnd Engineer&apo ...

The formatting of a nested JSON array will vary based on the specific conditions required by the API's request JSON

How should I structure a nested JSON array based on certain conditions from my form request JSON for an API? This is the JSON array from my frontend, created using Angular reactive forms. However, the API requires non-empty fields only. The array is nes ...

What is the best way to conceal a parent element with jquery?

Let's say we have the following HTML structure: <li class="fooli"> <a class="foo" href="javascript:foo(this);">anchor</a> </li> <li class="fooli"> <a class="foo" href="javascript:foo(this);">anchor</a> ...

Is the text represented in angular translate using the key instead of the value?

I've been diving into the localization section of ng-book and here's my progress so far: 1) I installed angular-translate using bower install 2) I included it in my HTML file using the script tag <script type="text/javascript" src="js/lib/ ...

How can I retrieve text instead of HTML using jQuery.get?

I'm facing an issue where I am trying to retrieve data from another site using the code below: jQuery.ajaxSetup({ crossDomain: true, dataType: "jsonp text" }); jQuery.get(url, function(rawContent) { console.log(rawContent); }); However, ...

How to dynamically add list items to a jQuery Mobile list using Ajax requests

Included in my index.html is a list view: <section id="dashboard" data-role="page" data-transition="slide"> <header data-role="header"> <h1>Trips</h1> <a href="#addTrip" id="createNewTrip" d ...

What is the best way to make my text stand out against a faded background?

After mastering the basics of web development on Codecademy, I was eager to start my own blog and create a unique website. One challenge I encountered was figuring out how to fade the background without affecting the text. Despite researching various solut ...

The AJAX request encountered an unexpected failure that cannot be identified (Using jQuery)

Are you facing issues with a service that returns JSON data? Check out this URL: If you're attempting a simple AJAX request, here's some sample code to get you started: $.ajax({ type: "get", url: "http://api.drag2droid.shamanland.com/ca ...

Navigating sub-domains swiftly

Having trouble setting up sub-domains and routing in Express Node. I need to direct users based on their device and browser type. If the user is on a desktop, they should be routed to web.. If they are on a mobile device, it should be mobile.. And if the ...

Using AngularJS to pass a parameter to a directive's template

My basic set looks like this HTML <linear-chart chartData="myArray" height="666"> </linear-chart> JS ... ... app.directive('linearChart', function($window){ return{ restrict:'EA', template:"<svg ...

Discover the steps for dynamically adding a new row in an Angular application

I am trying to add new rows to a table in Angular, but I'm having some trouble. Initially, there is one empty row, and when I click on the "add new" button after entering details, a new row should be added. I was able to do this using jQuery, but I&ap ...

Using a JavaScript class rather than an ID for toggling visibility

As a complete newbie to JavaScript, I've come across similar questions but I'm lost when it comes to coding - help needed! So here's the code I have so far, and I'm hoping someone can assist me. Currently, I have JavaScript set up to s ...

Automatically trigger a Bootstrap 5.2 modal when the page loads

Currently, I've been utilizing Bootstrap in conjunction with JQuery and have a specific code snippet that displays a Modal when a page is loaded. However, with the latest version 5.2 of Bootstrap, there is a push to move away from using JQuery (which ...

Combining Two DIVS Side by Side

Hey there, I am working on a timeline using two divs within a table cell. My goal is to have these divs overlap instead of appearing one below the other. The position attribute for all the DIVs inside the cell must remain unchanged due to the drag/drop fu ...

Steps for exporting a module from a JavaScript file that is linked:

When I include the main.js file in my project, the code below works properly: modules.exports = { property: value } However, if I include it in a web page like this: <!DOCTYPE html> <html> <head> <script src="main.js"& ...

Is there an easy way to use AJAX so that the page doesn't have to refresh

Currently, my local server is powered by Node.js and can be accessed at localhost:3000. This server hosts a static HTML page with a button embedded within it. When this button is clicked, I would like the server to direct me to localhost:3000/buttonClicke ...

The standard date format used in Javascript/Jquery programs

I have a kendo date picker set to display dates in the format "MM/dd/yyyy". I need to use jquery or javascript to ensure that the selected date is not in the future and is greater than '01/01/1900'. The problem I'm encountering is handling ...

Reducing the slide margins in impress.js?

When using Impress.js, I noticed that the default slides have a large left margin (or padding - it's hard to determine with Firefox's Inspector). I have a slide with a wide <pre> block that would fit if it were aligned to the left, but it d ...