Nodemailer Gmail timeout - node.js

I am having trouble with sending emails to my Gmail account.
I am getting a timeout error. And it puzzles me, because I basically copied the settings from a working project I did before.
But then I tried the working project, and it gives me the same error.
As far as I know Nodemailer's default port for Gmail is 465 which uses SSL, so this is turned on.
I have tried three different Gmail accounts, two have 2FA, one of them has setup XOAuth, the third I turned on less secure apps. Everything failed with the same error.
Here is the code snippet, where I think the trouble is:
smtpConfig =
service: "Gmail"
connectionTimeout : "7000" #waiting for 60s is annoying
greetingTimeout : "7000"
# auth:
# XOAuth2:
# user: receiverEmail
## pass: appSpecificPassword
# clientId: myClientId
# clientSecret: itIsMySecret
# refreshToken: myRefreshToken
auth:
user: receiverEmail
pass: appSpecificPassword
secure: true # use SSL
debug: true
I later put it into a function. In between I had to put the envelope together.
smtpTrans = nodemailer.createTransport(smtpTransport(smtpConfig), ->
#Setup configs are on top, because we need to config before we use the POST method according to express
)
This one doesn't even fire, when you put a console.log in there.
On Nodemailers Github I found the following to try out in the terminal:
openssl s_client -crlf -connect smtp.gmail.com:465
which should give a nice 200 response, but it doesn't, it gives me a timeout. Every other available port responded with the same.
I asked a friend to try it out on his computer and it works fine for him. So I am back searching for the problem on my computer - maybe on my operating system, node version, do we setup the configs differently and I didn't notice?
I am running out of options, so I am seeking for help here.
My firewall is off, no fuzzes about setting up extra ports in this case.

After extensive checking with my system and my internet provider I found that my router didn't like my internal IP address. So I renewed my DHCL leasing.
If you ever encounter the same problem, here are some tips for debugging.
Check for viruses: Along my deep research on the internet, I found the tip that viruses can block ports. So if you don't have a scanner, download one.
Check your firewall: Most common trouble. I checked my firewall and noticed it was offline.
Use network utilities: Do a port scan and try to ping the IP addresses
Check your email address with your local email client, try to send an email. Check incoming server and outgoing server configurations.
Check your network: Ask your provider if it is blocking email providers. Renew your network configurations.
Check your Google account if it is blocking your IP address. Happens often, if you send out a bunch of emails marked as spam, or if your account was hacked and used by somebody to send out spam.

Related

Mail of PHP, DNS request timed out, and FQDN

I want to make mail() of PHP work in my Windows Server 2012 R2. To this end, I first installed SMTP by following this page.
One thing that confuses me is the Full-qualified domain name. WIN-RFELH8GM0KN is what it proposes by default. My server hosts several websites, does anyone know which website I should specify here?
I did not change this, as a consequence, mail www.google.com in nslookup returns DNS request timed out. So is it an error?
Of cause, my test.php does not send the mail:
<?php
mail('mymail#gmail.com', 'title', 'content');
?>
Could anyone help?
Update 1 Following the answer of #LittleAI , I started SMTP, but DNS request timed out is still there:
Update 2 Here is php.ini:
telnet localhost 25 returns the follows:
Update 3 Here was a test, which worked well: I did receive the test mail in the inbox of softtitmur#gmail.com. However, if I redo the test in Update 1, there is still DNS requested time out.. And test.php still cannot send the mail...
Update 4 I just realised that in the page I followed, it is mail.vsysad.com under nslookup (I thought it was mail vsysad.com, that is why i tried mail www.google.com which did not make sense). So it works also in my server, and there is no DNS request timed out.
Then, I double checked php.ini, I realised that sendmail_from was not uncommented. So I uncommented it and set sendmail_from = softtimur#gmail.com, as a result, mail() of php works now, so the problem is solved, though I still don't understand FQDN and its default value (ie, WIN-RFELH8GM0KN)...
The first thing I noticed is that your SMTP Virtual service in IIS is not in a starting state so this would cause an issue. Make sure this service is in a starting state before testing.
The FQDN name is mainly used for the SMTP banner which the sender will be presented when connecting over port 25 to your server.
It maybe worth installing the DNS role onto your server and create a forward lookup zone referencing a fake domain e.g test.com and create an a record within this zone called SMTP using your servers IP. Make sure to then set your server to use 127.0.0.1 as the DNS provider so it can check record before delegating the reponse to root hints/external dns forwarder.
You need to do an SMTP request using Telnet to confirm SMTP is listening on port 25. You can do this by using the localhost ip address (127.0.0.1) as shown below:
telnet 127.0.0.1 25
helo test.com
MAIL FROM: ****YOUR EMAIL ACCOUNT****
RCPT TO: ****SENDERS ADDRESS****
DATA
You would probably not receive the email from your relay to GMAIL due to SPF Record which is in place that only allows certain IP/hostnames to send as google.com, but for testing you should see your server receive the mail after data has been inputted.
Here is the guide for using telnet on your server. Just make sure you have telnet feature installed as this is not installed by default.
http://www.yuki-onna.co.uk/email/smtp.html
Additional:
telnet localhost 25
After the SMTP banner type the following command in but make sure not to make any mistakes or else you'll need to probably start your sesssion all over again.
helo test.com
You should then see a 250 response to say the server is listening
The type the following:
MAIL FROM: test#test.com
It should respond with OK. If so, then type:
RCPT TO: ***YOU EMAIL ADDRESS OF CHOICE****
Again, it should respond with OK. If so, type the following:
DATA
Press enter after the DATA command. Your now into the body of the email. For testing purposes we will miss the subject bar and just add some data to the body.
This is a test email.
Then to complete the email you need to leave a blank line by pressing return, then a full stop, then return again like so.
***BLANK LINE****
.
***Hit Return****
Screenshot all the commands but you can blank out the email so I can see the output.

STARTTLS command first - Monit on Nectar Cloud Instance

I am testing Monit on a Nectar Cloud Instance, and am having trouble sending alerts when specific conditions are met. I am attempting to use gmail:
set mailserver smtp.gmail.com port 587 USERNAME "username" PASSWORD "password" using tlsv1
But when conditions are met, and emails are meant to sent, the log file shows:
Mail: 530 5.7.0 Must issue a STARTTLS command first. #randomstring - gsmtp
I have looked around other threads, and followed simple fixes like making sure less secure apps are allowed, but cannot find any Monit specific fixes. Any ideas?
Thanks in advance.

How to setup test SMTP server for devices on local network

I've been trying to figure this out for a couple days now. I've got a little linux box that should send email alerts and I need to test this functionality. It's a very, very basic linux box (painfully so).
Is it possible to setup a fake SMTP server on my desktop (IP:192.168.0.20) that it (192.168.0.2) can send emails to? I need to confirm that the messages are correct in content, but that's all. I'm perfectly fine having this spit out to the terminal. There's no DNS on the local network, or DHCP, I'm just using static IP addresses so it needs to work within that limitation.
I've been able to confirm with wireshark that the embedded computer is trying to do something over SMTP, but I don't see any message content at all, looks like it's just trying to talk to the server. I've also tried sending a message using "mail" but I keep getting an "SMTPclient: agent: unknown host" error, which I assume means it can't find the SMTP server I'm telling it to find.
I'm using Ubuntu 14.04 on my desktop.
Thanks!
So, as a basic test it works to just have an SMTP server running on your local machine. Installing Postfix should be all that's required. I set up the relay to our local mailserver but it wouldn't relay through. From the error messages I was getting I gather this is a DNS issue, it can't resolve where to direct the message. Watching wireshark you should be able to see the traffic and the attempt to send the message, which is something I guess. I will update when I have a better answer.

Mails Going to spam even after adding SPF and DKIM

I've configured Webmail in Cpanel, and enabled SPF and DKIM, but still the mails are going to spam in gmail. Yahoo is receiving the mails in inbox. My Domain and IP are not blacklisted. Please let me know if anyone knows the solution.
Nerdy Bird here! Have you by any chance tailed any of the exim error logs?
Try this:
Assuming you have root access to the server, ssh into the server as Root, the run the line below (NOTE: username is the beginning of the email address 'john#somedomain.com'. So in the below example, you would replace username with john). This makes searching the logs much easier).
tail -f /var/log/exim_mainlog | grep -i username
Upon running the above line, send an email from your webmail account to another account (Gmail in this case). Once you've done that, output should display in the terminal. The output is the best insight into your mail issue.
Also, if you have command line access, try using telnet. If you can connect by running the following line, you can rule out issues with outgoing ports on the server.
FOR PORT 25:
telnet alt2.gmail-smtp.in.l.google.com 25
If you get a connected message, port 25 is open and able to send mail.
FOR PORT 26:
telnet alt2.gmail-smtp.in.l.google.com 26
If you get a connected message, port 26 is open and able to send mail.
Other Possible Issues
You could possible not have a RDNS (reverse dns record) setup for your server's/domain's IP address. If not, please consult with your Hosting provider to see that gets added and allow time for propagation.
Port mail is being sent on is by default port 25. Sometimes ISPs' block mail coming from port 25. Try changing this port to port 26. This is typically done via command line or in WHM (Webhost Manager). If you do not have access to WHM or CMD, contact your hosting provider.
Although you stated your IP is not blacklisted, please check again. We use MXtoolbox.com
Hope this helps. Need more let us know.
Nerdy Bird
In my case, I tried a whole lot of things but at the end, I verified my site in https://www.google.com/webmasters and added it as a property after which email from my webmail started going to Gmail inbox again instead of spam.

JMeter imaps not working for gmail

I can't seem to get imaps for gmail working through the JMeter Mail Reader Sampler. It times out all the time (Error 500). I'm using the following settings:
Protocol: imaps
Server Host: imap.gmail.com
Server Port: 993
Username: xxx#gmail.com
Password: ******
Folder: INBOX
Security Settings: Use SSL
I've also tried using "Use StartTLS" without any luck.
Ensure you are using right port.
See into %JMETER_HOME%/bin/jmeter.log for possible error messages if still fails.
You can possibly try any other solution - via this java code from BeanShell Sampler, e.g..
I had many issues and finaly I managed to get e-mails from Gmail account, but only for IMAPS protocol. For POP protocol I did not manage to do it. First off all, you must allow IMAP in your Google account.
You can see how I resolve it here: How to check Emails from Jmeter

Resources