Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!