0

I'm trying to setup a simple contact form using nodemailer. All i'm trying to do is send an email to my email from the contact form. My email is "myemail@mac.com"

When I do my axios post I get an error in the data object saying: 550 5.7.0 From address is not one of your addresses. but yet the status:200 and statusText:"OK"

When I use the same from email as the icloud email "myemail@mac.com" then it works ? I dont see anything where it says you have to use the same from address as the service address ?

Axios post:

  const request = axios.post('http://localhost:3002/send', {'name':John Doe,'email':meme@gmail.com'});
  request.then((result)=>{
      console.log("request = ", result);
  }); 

Error message from console.log("request = ", result);

error:{
 code:"EMESSAGE",
 command:"DATA",
 response:"550 5.7.0 From address is not one of your addresses.",
 responseCode:550
}

nodemailer is my node.js

const transporter = nodemailer.createTransport({
  service: "iCloud",
  auth: {
    user: "myemail@mac.com",
    pass: "myemailpassword"
  }
})

    app.use('/send', function(req, res){
      var message = {
        from: req.body.email,
        to: 'myemail@mac.com',
        subject: 'Message From Portfolio Contact Form',
        //text: 'Plaintext version of the message',
        html: '<p>'+req.body.description+'</p>'
      };
      transporter.sendMail(message, function(error, info){
        if(error){
          res.json({error: error});
        }else{
          res.json({success: info.response});
        };
      });
    })
me-me
  • 5,139
  • 13
  • 50
  • 91

1 Answers1

0

You configure nodemailer transport with iCloud Service and you are trying to send a mail with a gmail adresse.

from: req.body.email, // meme@gmail.com
to: 'myemail@mac.com'

Which logically produces the error:

response:"550 5.7.0 From address is not one of your addresses."

You probably want to do the inverse.

TGrif
  • 5,725
  • 9
  • 31
  • 52
  • When you say send I presume you mean the From address ? So the configured icloud service address has to be exactly the same email as the from attribute in the message ? I'm not sure how changing the configured email to gmail would make a difference as it sates in the docs that you can use an icloud service. Thanks for the help – me-me Mar 30 '17 at 14:40
  • You can stick with iCloud, this is not a problem, but the From address need to be an authenticated user to the smtp service you use. Take a look at this answer: http://stackoverflow.com/a/16944453/5156280 – TGrif Mar 30 '17 at 15:37
  • Ah ok got it. I'll just go with adding the senders email to the body of the email. I saw your link and tried to change the name part of the from address but that caused an issue also. '"Joe Doe" '. If I can change the name then it doesn't look so weird when receiving the email in your machines mail application as your own name. – me-me Mar 30 '17 at 17:06
  • So for example I changed the from name to be. from: 'Contact Mailbox ' but the mail still comes into my mailbox as my name because I'm using myemail@mac.com and apple mail is seeing this as me even thought I changed the name to Contact Mailbox. Cn't seem to find any way around that ? – me-me Mar 30 '17 at 18:37
  • Yeah that's happen to me too when I tried with a gmail account. I'm not a email specialist but I think it is a common practice to use a dedicated email adress for send from in your app. – TGrif Mar 30 '17 at 18:53
  • Thanks for the help. – me-me Mar 31 '17 at 21:59