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.
Related
I am having username and password for a email account, but not smtp host name and port number,
I am using nodemailer.
Is it possible to send mail using only the username and password for the email account.
Edit: don't tell me to close, I have this doubt, If you know the answer tell me, this is not the silly thing, In my office they told me use only username and password. I searched online for it but did not got any idea.
You would always need smtp server details all the time along with username and password. And completely depends on smtp server how it handles the smtp details.
Few examples of smtp servers -
smtp.gmail.com
smtp.sendgrid.com
smtp.zoho.com
smtp.dreamhost.com
NodeMailer provides support for transports other than SMTP. You can check the link https://nodemailer.com/transports/. Looking in the documentation, it doesn't need SMTP server for these transports, you can give it a try.
In built support is there for below tansport.
sendmail – for piping messages to the sendmail command
SES – is a Nodemailer wrapper around aws-sdk to send mail using AWS SES
stream – is just for returning messages, most probably for testing
I've seen many blogs and stack overflow questions about setting up nodejs to use a pre-existing smtp server, especially through modules like nodemailer etc. Some of what I've already seen:
https://www.zeolearn.com/magazine/sending-and-receiving-emails-using-nodejs
Use smtp client to send email without providing password
How can I create a custom smtp server to send out notification emails in Nodejs?
Sending emails in Node.js? (DON'T KNOW WHY IT IS CLOSED)
Use smtp client to send email without providing password
Nodemailer with Gmail and NodeJS
Nodemailer send email without smtp transport -- this is a tiny bit closer to what I want
How can I create a custom smtp server to send out notification emails in Nodejs? -- this one is so close yet no answers
Sending email via Node.js using nodemailer is not working
SmtpJs API not working! is there any way to send emails using SMTP server with JavaScript or JQuery
Email NodeJS cannot send
Any suggestion for smtp mail server in nodejs? -- this one may be the only one that even attempts to answer it, although from the docs for the service mentioned there (smtp-server), I don't see where the actual makings of the SMTP server from scratch are, i.e. I don't see the part that shows how to make your own myemail#mydomain.com using nodeJS (assuming the NodeJS server is configured on some kind of linux VM like google compete engine).
All of these answers and blogs only addressed sending emails via some other email client.
I am not interested in any other email servers.
I don't believe in gmail -- or any other 3rd party email providers.
I want to host my own.
From my own computer.
Don't question my intentions.
It's a perfectly valid programming question:
How do I create, from absolute scratch (i.e., only using the "net" built-in library in nodeJS, no external dependencies at all) create a SMTP mail server (assuming I have my own domain registered at an HTTPS virtual machine somewhere), that has the ability to receive mails at myemail#mydomain.com, and send emails from myemail#mydomain.com, without any 3rd party servers at all.
How can I at least start to do this? Any possible reference or tutorial that deals with the SMTP socket protocols would be a great start.
Some friendly advice -- you probably want to use an off-the-shelf MTA like postfix, exim4, or sendmail if you just want to receive mail on your local machine.
I say this because I have literally spent a good hunk of my career implementing MTAs and feel I should warn you that this is a solved problem that allows you to have complete control over your mail traffic, and there are some very tricky issues to solve to write an MTA that works at scale with large mail volumes.
That said, SMTP (note spelling) is a very simple protocol, and a great "first protocol" to implement if you're interested in that stuff. It would be very easy to write one in NodeJS.
The first edition you'd be interested in was released some time around 1982, as RFC-821, aka IETF STD-10. It was then updated over the years to RFC-2821 and a bunch of related specs, but basic RFC-821 support will get you what you need to talk to 99% of hosts on the Internet today. (That number will go down as you need ESMTP support for TLS - but this is not much harder nor much different).
Your daemon will need to listen on port 25, and need to process commands like this:
YOU: 220 my.computer.com SMTP Service Ready
THEM: EHLO blah blah
YOU: 500 Syntax Error. Try again using SMTP.
THEM: HELO blah blah
YOU: 250 G'day mate
THEM: MAIL FROM: <billg#microsoft.com>
YOU: 250 Sender Okay
THEM: RCPT TO: <steve#apple.com>
YOU: 250 OK
THEM: DATA
YOU: 354 Enter mail, end with "." on a line by itself...
THEM: <BUNCH OF STUFF>
.
YOU: 250 Mail accepted
THEM: QUIT
YOU: 221 Goodbye
Obviously there is more here wrt error handling etc -- read the spec -- but this is the gist of it. The numbers are response codes and have specific meanings. The lines are separated by \r\n and are supposed to be less than 1024 bytes wide.
<BUNCH OF STUFF> is an email message, and will not have a line which is just a dot in it. If the email had a dot like that, the other end will send an extra dot. This is in the spec.
Finally, write <XXXX><BUNCH OF STUFF> into your $MAIL file (probably /var/mail/username or /var/spool/mail/username) and point your MUA at it. Pine, Alpine, Elm, or mutt would make a good MUA for sorting this stuff out.
<XXXX> needs to start with From (NO colon) and end with \n. This is the Berkeley mbox file format. It should reflect the MAIL FROM header in the SMTP transaction.
This file format is very common and supported by most POP3 and IMAP4 servers. You can probably also read it with Mozilla Thunderbird. I know Netscape Mail supported it back in the day.
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.
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.
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