Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda