0

i am facing with some strange (for me) behavior.
I am trying to create feedback form in my firebase app
Its a simple form which should send me a email when user submit it.

I created onCall function in my firebase app.

When i test it locally through firebase experimental:functions:shell its working and i receive a email, but deployed one always fails with:

{
code: "ECONNECTION"
command: "CONN"
errno: "ENOTFOUND"
}

the body of function:

function feedbacks(data)
{

    let email = createEmail(data);

    let transport = nodemailer.createTransport({
        host: 'smtp.yandex.ru',
        port: 465,
        secure: true,
        // tried this one, but without success too
        //tls:{ secureProtocol: "TLSv1_method" },
        auth: {
            user: 'xxxx@xxxx',
            pass: 'xxxx'
        }
    });

    return new Promise((resolve, reject) => {
        transport.sendMail(email, err => {
            if (err == null) {
                resolve(true);
            } else {
                reject(new functions.https.HttpsError('internal', 'failed', err))
            }
        });
    });

}

It seems that deployed function just can not access smtp server due to some firebase restrictions i don't know.

EDIT:
i tested deployed function with gmail smtp and my gmail credentials which i use in firebase too and it works.

The docs says, that i CAN use custom smtp while its port not 25.
If someone can shed light on that i would appreciate it.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
taburetkin
  • 313
  • 3
  • 17

1 Answers1

2

You need to be on the "Flame" or "Blaze" pricing plan.

As a matter of fact, the free "Spark" plan "allows outbound network requests only to Google-owned services". See https://firebase.google.com/pricing/ (hover your mouse on the question mark situated after the "Cloud Functions" title)

Since your SMTP server is not a Google-owned service, you need to switch to the "Flame" or "Blaze" plan.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121