Nodemailer works on local, but not works without displayunlockcaptcha on Netlify - smtp

I have an email verification feature through nodemailer in node server.
It works on localhost, but not works on Netlify once it's deployed.
Here are my codes.
const transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: "mygmail#gmail.com",
pass: "mypassword",
},
});
On live server, it occurs an error that -
Error: Invalid login: 534-5.7.14 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 195sm513587qkd.6 - gsmtp
I enabled "Less secure apps" in my google account.
And allowed https://accounts.google.com/b/0/displayunlockcaptcha as well
it worked a while, but since I cleared browser histories, it didn't work again.
So I allowed displayunlockcaptch again, it worked.
It means I should allow displayunlockcaptcha every times.
Is there any way to keep allowing it? Or any other way?

Related

Gerrit Cannot send email verification message 504

I am using gerrit 3.2.1
After I tried everything I can do to configure my gerrit.sendemail, I failed to send a verification mail
[sendemail]
enable = true
smtpServer = smtp.offce365.com
smtpServerPort = 587
smtpEncryption = ssl
sslVerify = false
smtpUser = gerrit#gerritserver.com
smtpPass = pswd
I refered to https://groups.google.com/forum/#!msg/repo-discuss/RWvdXR-Z4nA/1USSK1F6AAAJ\
but seems I met different problem,
For the encryption, according with office 365, the SMTP uses STARTTLS, but seems it always fail. I tried ssl, tls, neither works.
I also tried port 25.
[2020-06-16T14:33:53.834+0800] [WorkQueue-2] INFO com.googlesource.gerrit.plugins.deleteproject.fs.RepositoryCleanupTask : Cleaning up expired git repositories... Done
[2020-06-16T14:35:32.927+0800] [plugin-manager-preloader] INFO com.googlesource.gerrit.plugins.manager.OnStartStop : 66 plugins successfully pre-loaded
[2020-06-16T14:36:13.420+0800] [HTTP PUT /accounts/self/emails/name%40emailhost.com (flynn from 127.0.0.1)] ERROR com.google.gerrit.server.restapi.account.CreateEmail : Cannot send email verification message to name#emailhost.com
com.google.gerrit.exceptions.EmailException: Mail Error: Connection timed out (Connection timed out)
at com.google.gerrit.server.mail.send.SmtpEmailSender.open(SmtpEmailSender.java:437)
at com.google.gerrit.server.mail.send.SmtpEmailSender.send(SmtpEmailSender.java:207)
at com.google.gerrit.server.mail.send.OutgoingEmail.send(OutgoingEmail.java:225)
at com.google.gerrit.server.restapi.account.CreateEmail.apply(CreateEmail.java:164)
at com.google.gerrit.server.restapi.account.CreateEmail.apply(CreateEmail.java:121)
at com.google.gerrit.server.restapi.account.CreateEmail.apply(CreateEmail.java:71)
Is this related to this question on the mailing list?
Also, when I check the office365 smtp settings it looks like it should use tls instead of ssl:
SMTP Host: smtp.office365.com
SMTP Port: 587
SSL Protocol: OFF
TLS Protocol: ON
SMTP Username: (your Office365 username)
SMTP Password: (your Office365 password)
Try to change your settings to tls and maybe you need to implement the workaround for java11.
1 more tip when I come back to this 3 years later...
I met another problem with similar phenominal.
It turns out some mail server requires the field 'from' must be equal to 'smtpUser'.

Domain not found: AZF domain not created for application

I got this error while trying to configure level 2 authentication using idm,pep-proxy and pdp.
I am using latest version of authzforce,idm,pep-proxy but this error still persists.
config.azf = {
enabled: true,
protocol: 'http',
host: 'localhost',
port: 8080,
custom_policy: undefined // use undefined to default policy checks (HTTP verb + path).
};
part of config that is relevant.
As I understand idm connected with authzforce should auto create domains, but for some reason that is not case.
I have tried with different versions, read similar issues on stack but problem still persist.Any advice or maybe point what i am doing wrong would be really helpful.
Thanks

Using outbound Node-RED email to local SMTP server

I have a local SMTP email server I use for testing purposes running on my machine. It listens for SMTP on port 25. I am able to send and receive emails to it using a regular email client.
When I build a Node-RED flow that contains an e-mail output node and configure its properties with:
to: <email address>
server: localhost
port: 25
and submit a flow, I get the error:
25 Feb 16:43:24 - [error] [e-mail:<email address>] Error: 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:794:
I am at a loss on how to proceed. Looking at the messages, it almost appears that there is some form of SSL negotiation/test at play here. Switching on trace on my SMTP server, I find the following logs each time I try and run a flow:
"TCPIP" 10708 "2016-02-25 16:43:08.294" "TCP - 127.0.0.1 connected to 127.0.0.1:25."
"DEBUG" 10708 "2016-02-25 16:43:08.298" "Creating session 22"
"SMTPD" 10708 22 "2016-02-25 16:43:08.298" "127.0.0.1" "SENT: 220 WIN7-X64 ESMTP"
"DEBUG" 9772 "2016-02-25 16:43:08.299" "Ending session 22"
It appears that the Node-RED node is sending a connection request, getting back the SMTP 220 response and then failing immediately after that.
I came across the same problem and have a nasty hack that will enable mail to go via my local exchange server's plain SMTP, with no auth.
Edit the .../61-email.js file and change it thusly:
var smtpTransport = nodemailer.createTransport({
host: node.outserver,
port: node.outport,
secure: false,
ignoreTLS: true //,
// auth: {
// user: node.userid,
// pass: node.password
// }
});
I see Dave has replied to the github issue but just to close the loop on this question.
At this time (Feb 2016) the node assumes SSL is always available and enabled, at some point we need to go back to the email node and find a simple way to expose a lot more of the nodemailer options to allow connections to a wider range of email providers both public and private.

Google SMTP settings not sending email

I am having a hard time making the email sending in GitLab to work (changing email in profile settings). My server has exim4, I can tell its working because if I do simple mail() in PHP, it thus sends the email to the recipient. Now, in GitLab seems that it wasn't. So I modified productions.rb to have SMTP settings, and use Google SMTP:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 465,
user_name: "user#gmail.com",
password: "hashpassword",
domain: "gmail.com",
authentication: :plain,
enable_starttls_auto: true
}
I even tried changing the port to 587 and 467 but still it doesn't work. Why is that? Can you please lead me to where I am missing?

redmine email notifications with my own postfix server

I can't get redmine's email notifications to work. I am running my own mailserver with postfix using some mysql backend for the accounts. I added an account for redmine and tested it successfully using thunderbird. It is configured on port 25 using STARTTLS.
This is my config/configuration.yml of redmine:
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
tls: true
address: www.mydomain.org
port: 25
authentication: :login
domain: mydomain.org
user_name: tracker#mydomain.org
password: PASSWORD
As I said, the credentials work for sure. The port is 25 and the address is correct as well. Redmine is running on the same server, but using localhost as address doesn't work either.
The error message redmine is giving me reads
... (Connection timed out - connect(2)).
In the postfix log files, I can find nothing, not even an attempt to login or send an email. I am using Ruby 1.8.7 patchlevel 3xx and Rails 2.3.5. It seems like there is a problem with the connection in general, and not with my mailserver.
What can I do to find the source of the problem? I am not very familiar with how ruby works.
I figured it out... Below the commented, suggested configuration blocks in the configuration.xml file is another, uncommented email block, that reads
default:
email_delivery: ...
Even though I thought that by uncommenting the production: block these settings would be overridden, it started working the moment I inserted the email settings into this default block. This is a bit weird, but anyway - it does work now like a charm.