Closed tecoad closed 1 year ago
Probably an issue with the single quote on NEXT_PUBLIC_SMTP_FROM
My config with Sendinblue:
SMTP_USERNAME=baptiste@typebot.io
SMTP_PASSWORD=...
SMTP_HOST=smtp-relay.sendinblue.com
SMTP_PORT=587
NEXT_PUBLIC_SMTP_FROM="'Typebot Notifications' <notifications@typebot.io>"
I dont think that is the issue @baptisteArno, i have screenshot the video showing you setting up typebot from scratch:
DO you see if I am doing anything wrong?
Error after timeout:
Ok, I'm trying to reproduce with your creds
I've tried on Typebot and on https://dnschecker.org/smtp-test-tool.php. It fails on both places.
As far as I know, your credentials don't work 🤔
me too I'm getting the same error when I try to send an invite
Guys, this error means your SMTP credentials are not valid / working.
credentials
all of us?
I just checked my credentials and they are correctly working with other services (I use the same mail for other services) I don't understand. I there a way to have more verbose messages in the logs? I can't see anything that would help narrow my research...
For gmail smtp it's another story: https://nodemailer.com/usage/using-gmail/
I suggest you use a dedicated SMTP service like AWS SES, Brevo or Sendgrid.
I can confirm exactly the same issue with Postmark. Same creds are working on other services and also passes SMTP test with gmass.co/smtp-test
NEXT_PUBLIC_SMTP_FROM="'example' from@example.com"
(double quotes).
Did anyone facing this issue have any luck resolving this or more importantly, figured out the root cause?
Running Typebot on Docker.
@baptisteArno perhaps consider reopening this issue?
I can confirm exactly the same issue with Postmark. Same creds are working on other services and also passes SMTP test with gmass.co/smtp-test
NEXT_PUBLIC_SMTP_FROM="'example' from@example.com"
(double quotes).
Did anyone facing this issue have any luck resolving this or more importantly, figured out the root cause?
Running Typebot on Docker.
@baptisteArno perhaps consider reopening this issue?
Yeah @lazmo88 , I agree with you. this is an unresolved issue. I've been using the same exact credentials with other self-hosted services via docker containers flawlessly but when it comes to typebot it doesn't work. the problem is clearly linked to typebot but I don't know how to fix it.
I can confirm exactly the same issue with Postmark. Same creds are working on other services and also passes SMTP test with gmass.co/smtp-test
NEXT_PUBLIC_SMTP_FROM="'example' from@example.com"
(double quotes).
Did anyone facing this issue have any luck resolving this or more importantly, figured out the root cause?
Running Typebot on Docker.
@baptisteArno perhaps consider reopening this issue?
Yeah @lazmo88 , I agree with you. this is an unresolved issue. I've been using the same exact credentials with other self-hosted services via docker containers flawlessly but when it comes to typebot it doesn't work. the problem is clearly linked to typebot but I don't know how to fix it.
I tried looking at the logs, but there was nothing there related to emails.
@MAS-CREATIVE-LABS what email provider do you use? I'm thinking it is about the .env variables and how these are formatted.
Postmark issues username/password in xxxx-yyyy-aaaa... format, could the hyphens be the issue? I'll try saving these creds within quotation marks and see if that helps. Other a bit unclear part is the EMAIL FROM config, can we just use email address or do we need to specify also the name? This double quotation wasn't really well documented.
Comparing typebot to other self hosted apps, often you can just define admin creds as env variables or you are prompted to create admin creds on when logging in the first time. Fully working SMTP isn't normally a requirement.
What error do you see?
What error do you see?
There's no errors in the log, but emails are not sent so I can't login. Is there a way to enable debugging for emails?
Can you share the credentials to baptiste@typebot.io so that I try to reproduce?
Can you share the credentials to baptiste@typebot.io so that I try to reproduce?
Sent ☑
That worked for me. I received a login email 🤔
Is your VPS allowed to send email?
That worked for me. I received a login email 🤔
Is your VPS allowed to send email?
I'm running Typebot on local server, I am using the same SMTP credentials for other locally hosted apps and they work fine (n8n, Chatwoot, both running on same Docker VM).
Quite puzzling to be honest. Did you test the creds on latest Docker image?
Edit: As other apps are sending emails with same creds from same server, I doubt it's a ISP/port issue.
@tecoad @MAS-CREATIVE-LABS can you please advise your deployment method? Did you use Docker or other way of deploying the app?
@baptisteArno had no issues using the same creds, so question arises if there's an issue with the Docker compose config?
Can you share your docker-compose file so that I try to exactly reproduce your setup?
Can you share your docker-compose file so that I try to exactly reproduce your setup?
version: '3.3'
volumes:
db-data:
services:
typebot-db:
image: postgres:14-alpine
restart: always
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=typebot
- POSTGRES_PASSWORD=typebot
typebot-builder:
image: baptistearno/typebot-builder:latest
restart: always
depends_on:
- typebot-db
ports:
- '8080:3000'
extra_hosts:
- 'host.docker.internal:host-gateway'
env_file: .env
typebot-viewer:
image: baptistearno/typebot-viewer:latest
restart: always
ports:
- '8081:3000'
env_file: .env
And .env file
# Make sure to change this to your own random string of 32 characters (https://docs.typebot.io/self-hosting/docker#2-add-the-required-configuration)
ENCRYPTION_SECRET=XXX
DEBUG=true
DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot
NEXTAUTH_URL=typebot.local:8080
NEXT_PUBLIC_VIEWER_URL=bot.local:8081
ADMIN_EMAIL=XXX@XXX.COM
# For more configuration options check out: https://docs.typebot.io/self-hosting/configuration
# Email Auth v1
SMTP_USERNAME=XXX-XXX-XXX-XXX
SMTP_PASSWORD=XXX-XXX-XXX-XXX
SMTP_HOST=smtp.postmarkapp.com
SMTP_PORT=587
NEXT_PUBLIC_SMTP_FROM="'Typebot' <typebot@XXX.XXX.COM>"
SMTP_SECURE=true
SMTP_AUTH_DISABLED=false
For port 587
you should not set SMTP_SECURE
to true
. Do you confirm that you've also tried without SMTP_SECURE
variable?
For port
587
you should not setSMTP_SECURE
totrue
. Do you confirm that you've also tried withoutSMTP_SECURE
variable?
I have tested both, but isn't port 587 TLS/STARTTLS? So, secure flag should be true or am I missing something here?
I have also tested alternative ports specified by Postmark 25/2525/587.
To clarify, I have tried registering and logging in with the specified admin email, but none triggers email.
To be honest, I think there should be option to specify admin login in the env file and configuration of SMTP could be done on the admin dashboard with proper error/debug details if adding SMTP fails.
While above is quite significant change to whole config flow, there should be at minimum option to have more detailed debug logs available as its impossible to troubleshoot this issue without.
So the issue might come from:
NEXTAUTH_URL=typebot.local:8080
NEXT_PUBLIC_VIEWER_URL=bot.local:8081
Where does it come from, how did you set up these domains?
So the issue might come from:
NEXTAUTH_URL=typebot.local:8080 NEXT_PUBLIC_VIEWER_URL=bot.local:8081
Where does it come from, how did you set up these domains?
The local domains are setup with local DNS server and pointing to the Docker VM. No reverse proxy in the between.
So the issue might come from:
NEXTAUTH_URL=typebot.local:8080 NEXT_PUBLIC_VIEWER_URL=bot.local:8081
Where does it come from, how did you set up these domains?
Ok, so updating the urls fixed the issue!
Any thoughts why local:port urls didn't work?
Oh my bad, the format also is also invalid, it needs to start with http://
or https://
. That could be the issue?
To be honest, I think there should be option to specify admin login in the env file and configuration of SMTP could be done on the admin dashboard with proper error/debug details if adding SMTP fails.
Agreed. that's definitely the way to go. Obviously!
@tecoad @MAS-CREATIVE-LABS can you please advise your deployment method? Did you use Docker or other way of deploying the app?
@baptisteArno had no issues using the same creds, so question arises if there's an issue with the Docker compose config?
I apologize for the delayed reply, I was on a trip. her's my configuration: I'm hosting typebot on a Synology NAS with a reverse proxy (the same exact test machine I use for all my docker in my testing environment. I used portainer for the deployment of typebot and I followed the instructions from the official documentation.
`version: '3.3'
volumes: db-data:
services: typebot-db: image: postgres:14-alpine restart: always volumes:
db-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD=typebot
typebot-builder: image: baptistearno/typebot-builder:latest restart: always depends_on:
'host.docker.internal:host-gateway' env_file: stack.env
typebot-viewer: image: baptistearno/typebot-viewer:latest restart: always ports:
`ENCRYPTION_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXX
DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot
NEXTAUTH_URL=https://typebot.mydonmain.com
NEXT_PUBLIC_VIEWER_URL=https://bot.mydonmain.com
ADMIN_EMAIL=XXXXX@gmail.com
NEXTAUTH_URL_INTERNAL=http://localhost:3000
DEFAULT_WORKSPACE_PLAN=UNLIMITED
DISABLE_SIGNUP=false
NEXT_PUBLIC_BOT_FILE_UPLOAD_MAX_SIZE=250
SMTP_USERNAME=XXXXX@XXXXX.com
SMTP_PASSWORD=XXXXXXXXXXXXXXXXXXXX
SMTP_HOST=ssl0.ovh.net
SMTP_PORT=465
SMTP_SECURE=true
NEXT_PUBLIC_SMTP_FROM="'Typebot Notifications' XXXXX@XXXXX.com"
GOOGLE_CLIENT_ID=XXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=XXXXX-XXXXXXXXXX_XXXXX
GITHUB_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXX
GITHUB_CLIENT_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
FACEBOOK_CLIENT_ID=XXXXXXXXXXXXXXXXXXXX
FACEBOOK_CLIENT_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
NEXT_PUBLIC_GIPHY_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXX
NEXT_PUBLIC_UNSPLASH_APP_NAME=Typebot
NEXT_PUBLIC_UNSPLASH_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXX
DEBUG=true`
@baptisteArno I have 10 other Docker containers using the same credential flawlessly, the issue is only with Typebot. As suggested by @lazmo88 that settings should be taking place in the admin dashboard
i have the same issue No pending migrations to apply. â–² Next.js 14.1.0
Network: http://0.0.0.0:3000
✓ Ready in 1172ms [next-auth][error][SIGNIN_EMAIL_ERROR] https://next-auth.js.org/errors#signin_email_error Email(s) could not be sent { error: {
message: 'Email(s) could not be sent', stack: 'Error: Email(s) could not be sent\n' + ' at Object.s [as sendVerificationRequest] (/app/apps/builder/.next/server/chunks/524.js:1:3986)\n' + ' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' + ' at async Promise.all (index 0)\n' + ' at async email (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_nodemailer@6.9.3_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/lib/email/signin.js:31:3)\n' + ' at async Object.signin (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_nodemailer@6.9.3_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/routes/signin.js:115:24)\n' + ' at async AuthHandler (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_nodemailer@6.9.3_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/core/index.js:260:26)\n' + ' at async NextAuthApiHandler (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_nodemailer@6.9.3_react-dom@18.2.0_react@18.2.0/node_modules/next-auth/next/index.js:22:19)\n' + ' at async D (/app/apps/builder/.next/server/chunks/524.js:1:7871)\n' + ' at async K (/app/nodemodules/.pnpm/next@14.1.0@babel+core@7.22.9_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16545)\n' + ' at async U.render (/app/nodemodules/.pnpm/next@14.1.0@babel+core@7.22.9_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16981)', name: 'Error' }, providerId: 'email', message: 'Email(s) could not be sent' }
but if i telnet to my smtp server from the docker machine i can send a test email with the same credentials
Make sure your VPS has the SMTP port opened
@tecoad You should add this to nextjs.config
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
@salah-l , can i use this variable (NODE_TLS_REJECT_UNAUTHORIZED
) in .env file?
My error is: [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: mail.XXXX.online. is not in the cert's altnames: DNS:linux2.XXXX.com.br
@juliancesar
In node, the NODE_TLS_REJECT_UNAUTHORIZED environment variable controls whether or not the application will reject self-signed or otherwise untrusted certificates during SSL/TLS
By setting this variable to 0, you are instructing node to bypass the usual certificate validation process, allowing connections to proceed even if the certificates are not trusted.
You should know that this is not suitable for production environments due to security risks. It should only be used in development environments.
If you want to use this setting in a .env file, you should load the .env file at the top of main app file, which is why i suggested to add it directly to nextjs config and avoid the hustle.
Alternatively, you can set the environment variable directly when running the app from the command line like this
NODE_TLS_REJECT_UNAUTHORIZED=0 pnpm dev
this way, no need to update the config file
Error sending email: Error: queryA ETIMEOUT smtp.gmail.com at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:45:19) { errno: undefined, code: 'EDNS', syscall: 'queryA', hostname: 'smtp.gmail.com', command: 'CONN' } node:_http_outgoing:659 throw new ERR_HTTP_HEADERS_SENT('set'); ^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (node:_http_outgoing:659:11) at ServerResponse.header (C:\Users\nitis\Desktop\chat-app\backend\node_modules\express\lib\response.js:795:10) at ServerResponse.send (C:\Users\nitis\Desktop\chat-app\backend\node_modules\express\lib\response.js:175:12) at SendMail (C:\Users\nitis\Desktop\chat-app\backend\model\send.module.mail.js:28:21) { code: 'ERR_HTTP_HEADERS_SENT' }
same error
@juliancesar
In node, the NODE_TLS_REJECT_UNAUTHORIZED environment variable controls whether or not the application will reject self-signed or otherwise untrusted certificates during SSL/TLS
By setting this variable to 0, you are instructing node to bypass the usual certificate validation process, allowing connections to proceed even if the certificates are not trusted.
You should know that this is not suitable for production environments due to security risks. It should only be used in development environments.
If you want to use this setting in a .env file, you should load the .env file at the top of main app file, which is why i suggested to add it directly to nextjs config and avoid the hustle.
Alternatively, you can set the environment variable directly when running the app from the command line like this
NODE_TLS_REJECT_UNAUTHORIZED=0 pnpm dev
this way, no need to update the config file
My certificates are correct but it still didn't work, I disabled node tls and it worked perfectly.
Error sending email: Error: queryA ETIMEOUT smtp.gmail.com at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:45:19) { errno: undefined, code: 'EDNS', syscall: 'queryA', hostname: 'smtp.gmail.com', command: 'CONN' } node:_http_outgoing:659 throw new ERR_HTTP_HEADERS_SENT('set'); ^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (node:_http_outgoing:659:11) at ServerResponse.header (C:\Users\nitis\Desktop\chat-app\backend\node_modules\express\lib\response.js:795:10) at ServerResponse.send (C:\Users\nitis\Desktop\chat-app\backend\node_modules\express\lib\response.js:175:12) at SendMail (C:\Users\nitis\Desktop\chat-app\backend\model\send.module.mail.js:28:21) { code: 'ERR_HTTP_HEADERS_SENT' }
same error
You should use a dedicated SMTP service like @baptisteArno suggested, I think there's an issue with gmail. You can try Brevo they have free service up to 300 email/day
Solution that worked for me: When setting NEXT_PUBLIC_SMTP_FROM ensure you have it in the format SENDER_NAME< emailaddress > e.g. NEXT_PUBLIC_SMTP_FROM=Example Support < example@support.com >
NEXTAUTH_URL and NEXTPUBLIC VIEWER URL I put the same name and domain. My ".env" that works is the following:
ENCRYPTION_SECRET=ZfIOlwkCcCS91euNCV8fRsJi4WAHONO3 DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot NODE_OPTIONS=--no-node-snapshot
NEXTAUTH_URL=https://hostabc.yourdomain.com NEXT_PUBLIC_VIEWER_URL=https://hostabc.yourdomain.com
DEFAULT_WORKSPACE_PLAN=UNLIMITED
ADMIN_EMAIL=youruser@yourdomain.com SMTP_USERNAME=youruser@yourdomain.com SMTP_PASSWORD=xbxbxbxbxbxb SMTP_HOST=yoursmtp server SMTP_PORT=465 SMTP_SECURE=true NEXT_PUBLIC_SMTP_FROM=youruser@yourdomain.com
I have tried to setup several different SMTP providers to be able to send email:
Sendinblue (brevo), Postmark, Resend.com. My SMTP settings should be right since a was able to test through a SMTP connection testing system https://www.gmass.co/smtp-test.
My enviorment variables are:
I cannot get it to work regardless of the service I use. All of them timeout, both locally and deployed (vercel) versions. All of them have the same error:
err:
And try and catch
I have already tried: Ports 2525, 25 and 587. Local and deployed
Also, its not clear for me the function of DEBUG=true env. Since enabling it changes not logs on the console.
Update 1:
Some behaviour that seems need to be more clarified:
So far, i had these envs:
NEXTAUTH_URL=http://localhost:3000/ NEXT_PUBLIC_VIEWER_URL=http://localhost:3001/
After some reasearch, even thought the logical would be this set to localhost, i changed to a deployed url, then set the NEXTAUTH_URL_INTERNAL=http://localhost:3000/
Now, i can see the message "A magic link email was sent. 🪄 Make sure to check your spam folder."
However email has not been sent (checked the logged messages from my postmark).
IMO, Documentation is unclear if NEXT_PUBLIC_VIEWER_URL and NEXTAUTH_URL should be deployed versions url. Github or others auth methods are working perfectly, even before NEXTAUTH_URL_INTERNAL env. This issue has been extremelly difficult to track as it seems a internal nodemailer issue and nothing seems to work. Any clue would be highly appreciated.
Update 2:
It seams that the issue I am having is the same as some people show in this recent discussion here, even though not presented much tracing details.