0

I am using a custom email on a custom domain and trying to send emails to clients. On the node side the response shows the email is sent but can't see it on the reciever's input box.

var transporter = nodemailer.createTransport({
host: 'mail.example.com', 
port: '587',  
secure: true , 
auth: {
user: "noreply@example.com", 
pass: 'password' },
tls:   rejectUnauthorized:false , 
           }
            
            
       });
transporter.sendMail(mailOptions,function(error,info){
                    if (error) return 400; 
                    
                    else {
                        
                        console.log(info) ;
                        return 200 ; 
                    }
           });
Madhu Paka
  • 51
  • 6

2 Answers2

0

Are you sure this is the code that is able to send messages? There is a { missing in key tls.

And try changing the port to 465 (Though it's deprecated)

dreygur
  • 300
  • 3
  • 12
  • Yeah, I think I made a mistake in pasting the code, the code is correct as far as I know. – Madhu Paka Mar 09 '22 at 08:00
  • Can you provide the log? – dreygur Mar 09 '22 at 08:04
  • accepted: [ 'msraut2002@gmail.com' ], rejected: [], envelopeTime: 83, messageTime: 36, messageSize: 371, response: '250 OK id=1nRrFr-003Iu7-Lj', envelope: { from: 'noreply@example.in', to: [ 'msraut2002@gmail.com' ] }, messageId: '<7bc4c7fa-28b5-79da-3c12-fd98ce92851c@example.in>' – Madhu Paka Mar 09 '22 at 08:06
  • Yeah, the log says the message is sent(if you have changed the from field before pasting it here). Please check your mailbox's spam section. There should be the email. – dreygur Mar 09 '22 at 08:10
  • Yeah I have changed the from email, and also I have checked the spam box. It's not there. – Madhu Paka Mar 09 '22 at 08:14
0

found out the issue. idk why, but when I added the optional parameter in transporter: name: "www.domain.com" it started working.

Madhu Paka
  • 51
  • 6