Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
Javascript mail

I am using smtp.js to send mails to my email id whose credentials i made using smtp.js.I made a contact form where i want the user to enter his info and email and that should be sent to my email.So according to this logic, my mail should be in To property and sender's mail should be in the From property.However, when i run the code, it throws an error as "Mailbox name not allowed. The server response was: Envelope FROM 'sendername@gmail.com' email address not allowed.". If not possible,can u tell me some other alternative using js.Thanks Code:

function sendmail()
    {
    
            var name = $('#name').val();
            var email = $('#email').val();
            var phone = $('#phone').val();
            var address = $('#address').val();
            var postal = $('#postal').val();
            console.log(typeof(email))
            // var body = $('#body').val();

            var Body='Subject: '+"Estimated Quote"+'<br>Name: '+name+'<br>Email: '+email+'<br>Phone: '+phone+'<br>Address: '+address+'<br>Postal Code: '+postal+'<br>Quote exl VAT: '+vat_excl+'<br>Quote incl VAT: '+vat_incl;
            //console.log(name, phone, email, message);

            Email.send({
                SecureToken:"2d019ac3-046b-4c4f-94e2-f4f3bf08fb1f",
                To: 'saadalimalik4@gmail.com',
                From: email,
                Subject: "New mail from "+name,
                Body: Body
            }).then(
                message =>{
                    console.log (message);
                    if(message=='OK'){
                    alert('Thanks for submitting details.We will contact you soon.');
                    }
                    else{
                        console.error (message);
                        alert('Error submitting form.')
                        
                    

}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't know which library are you using to stablish the SMTP connection, but first of all make sure that the SMTP sever accepts all the domains that you're requiring.

I'd suggest you to use nodemailer which is fairly easy to use.

Example:

// CONFIG SETUP
import { createTransport } from 'nodemailer';

const Transporter = createTransport({
  host: process.env.SMTP_HOST || 'localhost',
  port: Number(process.env.SMTP_PORT) || 25,
  secure: false,
  tls: { rejectUnauthorized: false }, // THIS WILL BE ACCORDING TO YOUR SMTP CONFIG
});

// EXAMPLE OF USAGE
const info = Transporter.sendMail({
      from: 'sender@test.com',
      to: 'to@test.com',
      subject: 'TEST',
      text: 'TEST',
    });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda