I am struggling with sending emails through nodemailer

Every time I attempt to send an email using my contact form, I encounter an error message stating that the 'address being used does not belong to this platform'. The issue lies in the fact that I am trying to send the email from a different platform than the one I am using to receive messages. It seems that individuals must use an account registered with the o2.pl platform in order to send an email. Below is the code snippet:

const transporter = nodemailer.createTransport({
  host: 'poczta.o2.pl',
  port: 587,  
  secure: false,
  auth: {
    user: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="650008040c09250a574b1509">[email protected]</a>',
    pass: 'password'
  }
})
const mailOptions = {
  from: req.body.email,
  to: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcb9b1bdb5b09cb3eef2acb0">[email protected]</a>',
  subject: `message from ${req.body.email}: ${req.body.subject}`,
    text: req.body.message
  }
  transporter.sendMail(mailOptions, (error, info) => {
    if(error){
      console.log(error);
      res.send('error');
    }
    else{
      console.log('Email sent: ' + info.response);
      res.send('success')
    }
  })
})

Furthermore, here is another code example:

const contactForm = document.querySelector('.contactFormm');

let email = document.getElementById('email');
let name = document.getElementById('name');
let subject = document.getElementById('subject');
let message = document.getElementById('message');

contactForm.addEventListener('submit', (e)=>{
  e.preventDefault();
  let formData = {
    email: email.value,
    name: name.value,
    subject: subject.value,
    message: message.value
  }
  let xhr = new XMLHttpRequest();
  xhr.open('POST', '/');
  xhr.setRequestHeader('content-type', 'application/json');
  xhr.onload = function(){
    console.log(xhr.responseText);
    if(xhr.responseText =='success'){
      alert('Email sent');
      email.value = '';
      name.value = '';
      subject.value = '';
      message.value = '';
    }
    else{
      alert('Something went wrong!')
    }
  }
  xhr.send(JSON.stringify(formData))
})

Answer №1

Your initial code snippet appears to be in good shape. I recommend testing it with gmail to verify if there are any problems specific to poczta.

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

JavaScript function to display the anchor tag's title attribute in a modal when clicked

I am curious if you can assist me in finding the right path here. I have a PHP code that I would like to use onclick on dynamically created links to show the link's title in a modal window with a close option, similar to a tooltip. I prefer not to use ...

Decoding PDF417 Barcodes with ZXing.NET using HTML5 Video

I'm currently exploring the use of jQuery/JavaScript in conjunction with ZXing.NET to decode a PDF417 barcode from a video source. Below is the HTML I am working with: <video id="video" width="800" height="800"></video> <canvas id="ca ...

Utilize socket.io for sending broadcast messages alongside the fetch API

My current setup involves using the fetch API to post and retrieve user data, which is working well. However, I also want to incorporate socket.io into fetch to emit and broadcast selected data from a MySQL database. On the server-side: var server = requi ...

Attempting to utilize PFUser within a NodeJS environment

I have been utilizing the PFUser class to generate user accounts for individuals using an iOS application to access a Parse-Server. Now, I am looking to transition this user management functionality from an iOS app to a web app (specifically NodeJS). Init ...

What is the best way to make a full width div within a container using bootstrap?

Imagine you have the following code snippet: <div class="container"> <div class="row"> <div class="col-md-12"> ... <div class="full-width-div"> </div> </div> & ...

"Troubleshooting: The Challenge of a Persistent Footer's

I came across a sticky footer that met my needs, but now I am facing an issue. When I increase the resolution beyond my normal setting, the code works fine but there is spacing between the container div and the footer div. I have attached a screenshot to s ...

Creating a main navigation menu

In search of: creating a basic links/navigation bar. My CSS snippet: .ico { width:40px; } The HTML code I currently have: <body> <div id="logo"> <img src="logo.png" id="test" /> <img class="ico" src="images/home.png" /> ...

Customize the background color of Material UI input components on standard labels

Currently using react material ui and interested in changing the background color of a standard input. The issue arises when the label is overridden by the background color when the input is not selected. Input selected Input not selected This is my att ...

Tips for making text flow around an image

How can I achieve a design where the text wraps around an image positioned in the bottom right corner? [Image Removed by Owner] Your guidance on implementing this effect is greatly appreciated. Thank you. ...

Using conditional rendering to set an icon in a ChipField component in React Admin

One feature in my React Admin App is a Datagrid with a ChipField displaying a text property. I want to enhance this by adding an icon to the ChipField using the icon prop, which should change based on the text value. This is my current approach: expor ...

Is there a way to achieve horizontal alignment for the Twitter and Facebook buttons on my page?

By utilizing the html code provided, I successfully incorporated Twitter and Facebook "Like" buttons into my website. Initially, they were stacked vertically, which resulted in excessive use of vertical space. To optimize space usage, I decided to align th ...

Is there a way to transfer information from an HTML form directly into an Excel file using web services?

Recently, I created an email newsletter using HTML and CSS. This newsletter includes 4 text boxes where users can input their name, family name, phone number, and email address. I am wondering if it is possible to use a web service to transfer this data fr ...

CSS: Floating navigation bar that becomes fixed upon reaching the top of the page

Looking for a creative approach to achieve the following: An innovative navigation bar that initially appears on a page regularly but then becomes fixed at the top as I scroll down. An alternative perspective: imagine a navigation bar that starts off unf ...

Unable to style Vuetify components with CSS

I am currently following along with this tutorial and I have reached the part where Vuetify is being added. Despite matching my code to the tutorial, Vuetify does not seem to load on my end. In the comparison image below, the left side shows how it appear ...

Guide to picking Material UI Tab using URL

I'm currently exploring ways to control the selected tab through the URL. Initially, I am able to set the selected tab upon component loading by implementing this logic in the constructor: let selectedTab = 0; props.layout.map((element, index ...

The align-items property in Flexbox is not functioning as expected when applied to Link components contained within

I'm in the process of creating a simple navigation bar using flexbox, but I'm encountering an issue where the content within the unordered list is not vertically centered. Below is the HTML code snippet: *,*::before,*::after{ margin: 0; ...

What methods can I use to teach emacs to distinguish between my PHP, HTML, and JavaScript code as I write?

While working with emacs and writing PHP, I often find myself needing to include HTML code and would appreciate a way to differentiate the syntax highlighting between PHP and HTML. Similarly, when adding JavaScript to an HTML file, I would like to know h ...

How to Bind Data when a Textbox Loses Focus?

I need to validate a user-entered value against a value retrieved from the database using a JavaScript function. Below is the code snippet I am currently using: <asp:TextBox ID="txtNoDays" runat="server" Width="49px" onblur="return NumericChk(this,&ap ...

"My original CSS styles are being overridden by a template page's CSS code

I am encountering an issue where the fonts in my application are getting changed when I include a template page called template.html with CSS that includes body{ font-family:'Arial'}. The template page is being included using 'ng-include&apo ...

Attempting to decipher the @media queries CSS code responsible for the slider on this particular website

I'm having trouble with the cover not fully expanding when the browser size is less than 750. I am new to using bootstrap. For reference, I am looking at this website: CSS .slide-wrapper { position: relative; } /* Not using now .carousel-caption ...