Code Monkey home page Code Monkey logo

Comments (39)

ctwhome avatar ctwhome commented on August 29, 2024 8

Hi! After all the services that firebase provides to create extremely fast, complex, realtime applications... Having to use a third party like sendgrid to handle emails seems odd to me. I mean, for an application sending emails to customers is fundamental, why is this not being part of the core functionalities of firebase? Maybe firebase hosting?

from extensions.

Niweera avatar Niweera commented on August 29, 2024 7

For those who are still struggling with GSuite emails for the Email Trigger Extension. I think I may have found a solution. As the OP says I was stuck at the PROCESSING state and nothing happened when I gave the smtps URI as smtps://[email protected]:[email protected]:465.

However when I used a password without any special characters it worked.
NB: The following settings were set for the GSuite email account.

I have the same problem with the GSuite account. I allowed access from Less Secure Apps but nothing. It doesn't work. I have also tried all possible combinations with port 587 and without it.
image

@ctwhome pls try this and find out whether it worked for you or not.

from extensions.

barrylachapelle avatar barrylachapelle commented on August 29, 2024 5

I had the same issue - my challenge was that my email was a GSuite account and I needed to allow access from Less Secure Apps. I had to go into my GSuite account, Security allows Users to Set own Less Secure Apps. Then set it for my email.

It was a bit of a struggle but I hope that helps someone.

from extensions.

rphlmr avatar rphlmr commented on August 29, 2024 2

@Ehesp oh yes 🤦‍♂️
If it can help @aq2 , I have this config (working):
smtps://[email protected]:[email protected]:465

from extensions.

MatteoStohlman avatar MatteoStohlman commented on August 29, 2024 2

However when I used a password without any special characters it worked.

I URL encoded the special characters in my password and that worked fine.

Have it working with

  1. Less secure apps setting
    68124025-ac7cdd00-ff0e-11e9-8f1a-3871b17cf3b2

  2. SMTP Server
    smtps://[email protected]:veryComplicatedPassword%21%[email protected]:465

NB. from email same as auth email although idk if that is necessary

@Niweera

from extensions.

laurenzlong avatar laurenzlong commented on August 29, 2024 2

Hi, we are not planning to offer an email service within Firebase in the forseeable future.

It seems like the workaround in #41 (comment) is the best approach. Perhaps we can document this more clearly.

from extensions.

ctwhome avatar ctwhome commented on August 29, 2024 1

If it helps, what I did for GMAIL account:
smtps://[email protected]:[email protected]:465
and then a enable "Less secure app access"
https://myaccount.google.com/u/2/lesssecureapps

I didn't manage to use my GSuite account tho yet.

from extensions.

bdiz avatar bdiz commented on August 29, 2024 1

Trying to debug the function. Upon the create of the initial document the cloud function updates attempts to 0 and state to PENDING. But what I see when observing the document in the firebase console is attempts are 0 and state is PROCESSING.

Looking at the switch statement for PENDING, it sets state to PROCESSING and then should call deliver().

case "PENDING":
case "RETRY":
// Wrapping in transaction to allow for automatic retries (#48)
await admin.firestore().runTransaction((transaction) => {
transaction.update(change.after.ref, {
"delivery.state": "PROCESSING",
"delivery.leaseExpireTime": admin.firestore.Timestamp.fromMillis(
Date.now() + 60000
),
});
return Promise.resolve();
});
return deliver(payload, change.after.ref);

However, if deliver() was called at all, why would attempts remain 0? My logs confirm that the "Attempting delivery..." message is not present either.

These observations match with earlier reports: The original post shows attempts 0 (#41 (comment)). and a later comment shows a log that does not have a "Attempting delivery..." message (#41 (comment)).

Is there something with await admin.firestore().runTransaction where it might be hanging there (though update of state to PROCESSING goes through)? I see there is a comment in the code about issue #48. Not sure if the issues there are still causing issues with this firebase extension.

@Ehesp can we reopen?

from extensions.

manglide avatar manglide commented on August 29, 2024 1

I also had the same issue, trying to send with a gmail account (not G-Suite).

What worked:

  1. Allow less secure apps on the gmail account - https://myaccount.google.com/lesssecureapps
  2. URL encoding your password with https://www.urlencoder.org/ if it has special characters.

The above 2 steps did the trick.

from extensions.

Ehesp avatar Ehesp commented on August 29, 2024

Hi @aq2 - Would you be able to check the Firebase Functions logs to see if any error is occurring?

from extensions.

aq2 avatar aq2 commented on August 29, 2024

okay thanks,

i'm just testing this with a simple button on my website that adds a document to my 'mail' collection

i press the button, see the new doc in the collection, but it stays at 'processing' - no errors shown in 'delivery' field - just says 'null' and 0 attempts

logs don't seem to give any obvious error messages, but it eventually times out

i'm not sure what you want to see...
fb-logs

from extensions.

rphlmr avatar rphlmr commented on August 29, 2024

@aq2 Hello :)
I don't see an "smtpConnectionUri" on your extension's configuration. Is it normal ?

from extensions.

Ehesp avatar Ehesp commented on August 29, 2024

@rphlmr It's omitted as it's a sensitive field.

I'll try this out myself using my own Gmail account as the SMTP provider. My initial thinking is that node-mailer is forever trying to connect to the SMTP server and eventually timeout the function.

@aq2 would you be able to try smtps:// rather than smtp://? The Gmail SMTP server requires SSL by the looks of it.

from extensions.

aq2 avatar aq2 commented on August 29, 2024

hi - thanks for your inputs,

I have managed to get it working using a different email provider, but am still unable to use with gmail, whether using smtp or smtps

I have heard that gmail are quite a large email company and i am surprised that i can't get the extension working with them.

@Ehesp did you manage to get gmail working?

from extensions.

Ehesp avatar Ehesp commented on August 29, 2024

Could you try setting the from address as your own email used for Gmail?

from extensions.

aq2 avatar aq2 commented on August 29, 2024

sorry, not quite sure what you mean

i've been using the same email address in 'from' and smtp URI - ie my gmail address

or are you suggesting that i use gmail URI, but with a different from address - like 'send as'?

from extensions.

aq2 avatar aq2 commented on August 29, 2024

sorry - pressed the wrong button - didn't mean to close - whoops

from extensions.

Ehesp avatar Ehesp commented on August 29, 2024

That's ok then, I believe Gmail has restrictions around the from sender address having to be the same as the SMTP user.

Let me try and get Gmail sync'd up and I'll get back to you on whether I can get it working.

from extensions.

Niweera avatar Niweera commented on August 29, 2024

I have came across the same issue as the op. However, I tried with my gmail and it worked. ([email protected]). But I tried with a GSuite email ([email protected]) and it did not work for that email. The delivery state is stuck on PROCESSING and the cloud function is timing out after one minute. Any suggestion is appreciated.
Thanks in advance.

from extensions.

timsewell avatar timsewell commented on August 29, 2024

I am also having this issue. I've also now tried it with a Yahoo mail account and the same thing happens.
My function config:
image
(NB, I've also tried with smtps using port 587. I've tried with the normal account password and with a generated app-specific password. I'm kind of tearing my hair out here, so any help from anyone who has overcome this with any decent email provider would be extremely welcome. Thanks!

from extensions.

timsewell avatar timsewell commented on August 29, 2024

So, I don't think this is an issue with the email provider. I knocked up a quick and dirty nodemailer app and it worked perfectly with the same account details.

from extensions.

Ehesp avatar Ehesp commented on August 29, 2024

What Firebase plan are you on? Trying to replicate in the same environment.

from extensions.

timsewell avatar timsewell commented on August 29, 2024

Blaze

from extensions.

timsewell avatar timsewell commented on August 29, 2024

Hi @Ehesp - thanks for helping me with this. Further info - I've set up a custom function, triggered from the same collection, that uses nodeMailer to send the required emails and it works fine using my email account details that weren't working with the ready-made email trigger. I've had a look at the source of the ready-made one and nothing jumps out at me. Could it be to do with the way the smtp url string is being parsed? I notice that the collection document gets updated with attempts: 0, whatever config etc I tried and even when errors were reported.

from extensions.

timsewell avatar timsewell commented on August 29, 2024

I couldn't do that with my initial email account as it has 2FA. However, I followed the various instructions for that, including an app-specific password and didn't have any joy. Then I set up another GMail account without 2FA and followed the allow-less-secure and recaptcha settings - still didn't work. It's the latter account that I have working fine, now, with my own cloud function. It's weird how this seems to work for some users and not for others.

from extensions.

ctwhome avatar ctwhome commented on August 29, 2024

I have the same problem with the GSuite account. I allowed access from Less Secure Apps but nothing. It doesn't work. I have also tried all possible combinations with port 587 and without it.
image

from extensions.

timsewell avatar timsewell commented on August 29, 2024

Thanks - and I'm glad you got it working. I've found that my custom cloud function does everything I need it to do, so I've moved on to other areas of functionality.

from extensions.

logemann avatar logemann commented on August 29, 2024

For all fighting with the correct connection URL, it might help to consult nodemailer documentation. https://nodemailer.com/smtp/

The extension just passes the connection URL as is to nodemailer. I stopped trying with gmail cause of 2FA. Testing can be better done with mailservices like sendgrid or mailgun. They have free plans and offer a SMTP gateway which one can use.

from extensions.

ctwhome avatar ctwhome commented on August 29, 2024

For all fighting with the correct connection URL, it might help to consult nodemailer documentation. https://nodemailer.com/smtp/

The extension just passes the connection URL as is to nodemailer. I stopped trying with gmail cause of 2FA. Testing can be better done with mailservices like sendgrid or mailgun. They have free plans and offer a SMTP gateway which one can use.

Isn't it the idea of the extension to handle this without extra impediments?

from extensions.

Niweera avatar Niweera commented on August 29, 2024

@MatteoStohlman yeah, I did the same. It's working fine for me.

from extensions.

ravpacheco avatar ravpacheco commented on August 29, 2024

Hi guys, any update about this issue?

from extensions.

shaisa avatar shaisa commented on August 29, 2024

Had the same issue until I encoded the password - you can check it here to make sure https://www.urlencoder.org/

from extensions.

ravpacheco avatar ravpacheco commented on August 29, 2024

Hi @shaisa, I had not only encoded the password but also changed to a simple password, without special character.

I believe google functions has some problem to execute Nodemailer with a provider different than Google. When I try to send an email with my email provider anything works.

I have tried locally with Firebase Functions Emulator and in a vanilla Node.js. The code works fine in a vanilla node.js application but doesn't work with Firebase Function.

from extensions.

shaisa avatar shaisa commented on August 29, 2024

Mmmm.... You know what - I couldn't make the extension to work with my g-suite smtp-relay as well...
I guess gmail is the only one working right now. And the logs are worthless to understand why.

If only someone from google was here to help ;)...

from extensions.

mbleigh avatar mbleigh commented on August 29, 2024

from extensions.

shaisa avatar shaisa commented on August 29, 2024

Of course - at least on my end this is not the case - this is a part of evaluating the extension in terms of usability and limitations (btw, not all use cases are for mass mailing so I wouldn't dismiss this issue because of that).
When something doesn't work without understanding why - it is a sign for me that there might be more "black holes" down the road and I take it into consideration before moving it to production.
Maybe it's a good idea to add a log when this error occurs in the extension or a known issue somewhere to notify people of this bug (/feature). Even a small "G Suite smtp-relay is not supported" message in the configuration GUI / CLI would do the job and save time for people trying it...

from extensions.

bdiz avatar bdiz commented on August 29, 2024

I don't think it's a gmail/gsuite specific issue. I am getting an indefinite PROCESSING status with Postmark. My smtp URI looks like smtp://abcdef-1234:[email protected]:25. Postmark uses an api key with only hex characters and dashes so special characters doesn't seem like it would be the issue in my case. The password and username for postmark are the same.

I tried this smtp URI with nodemailer in a node repl locally and I was able to send an email successfully so it doesn't seem to be Postmark.

I previously was using SendGrid with this extension and I had emails working.

Complicating my debug data is I upgraded the extension from node 8 to node 10, but I'm not sure that has anything to do with seeing this issue since I never tried Postmark on node 8. Nor have I tried SendGrid on node 10. Trying to reactivate my SendGrid account to see if I can get that working again (they deactivated me without notice (I'm thinking due to low volume), which is what sent me on this goose chase in the first place).

from extensions.

bdiz avatar bdiz commented on August 29, 2024

@Ehesp , do you want me to file a new bug? Node 10 simply won't send an email for me.

from extensions.

L96Github avatar L96Github commented on August 29, 2024

Also had this problem and removing the special characters from the password worked for me as well! Thanks 🙏🏽

from extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.