Can't send mail with Cloud Functions for Firebase

元气小坏坏 提交于 2020-06-23 16:01:49

问题


I'm trying to send an email from a Cloud Function using the sendmail package. It works when I host my "send function" locally. And I can deploy the function without problems to my Firebase project.

In the log at Firebase I can see this message:

Error: queryMx ESERVFAIL hotmail.com
at errnoException (dns.js:28:10)
at QueryReqWrap.onresolve [as oncomplete] (dns.js:219:19)

I'm neither familiar with sending emails from servers or Cloud Functions for Firebase. My question is why I got this error and how I can make it work?

Here is an excerpt from my function:

sendmail({
        from: body.name + ' ' + '<' + body.email + '>',
        to: 'soerensmed@hotmail.com',
        subject: 'Henvendelse via kontaktformular',
        html: html,
    }, function (err, reply) {
        if (err) {
            console.log(err && err.stack);
            response.status(500).end()
        }
        else {
            console.log(reply)
            response.status(200).end()
        }
    });

I'm developing a website where people can contact me through a contact form. The goal is to receive an email with the message... If this approach isn't possible I'm open for suggestions on how I can set this contact-email-thing up using Angular and Firebase.


回答1:


It will not work with cloud function with free spark account. You should upgrade as it is clearly defined in pricing section in network box. https://firebase.google.com/pricing/



来源:https://stackoverflow.com/questions/45551840/cant-send-mail-with-cloud-functions-for-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!