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))
})