Sent Email in Google Cloud Service - email

I have some doubts regarding configuring email in Google Cloud service with existing applications
1.we configured the SMTP using gmail account with port 587 & try to sent mail from our google cloud instance, no email is sent.We try to ping to the port 587, it shows connection refused. Why it is happened?
2.we have seen an option to sent email using SMTP-Relay in Google cloud platform. How can we configure & setup SMTP with Google Apps email/gmail using SMTP-Relay set up?
Is there any option to send emails from google cloud for our existing application like mantis without using third-party partners like SendGrid, Mailgun and Mailjet?

I was able to send email from our Google Compute instance using following mailx command:
# the body of the alert email is saved to a temprary file
echo "Hello. This is a test message" > /tmp/mail_body.txt
# the mailx command is used to send the email. it sends the email using gmail server.
# this is useful on servers that have limited access to email servers such as Google Compute instance
mailx -s "Email Subject" -r "reply_email" -S smtp="smtp.gmail.com:587" -S \
smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="gmail_address" -S smtp-auth-password="gmail_password" -S \
ssl-verify=ignore recepiant_email < /tmp/mail_body.txt
# the temprary file is removed
rm -rf /tmp/mail_body

You cannot use port 587 since GCP block all outbound traffic from that port, I suggest you use port 2525 since that's the only smtp port that GCP does not block.

Google Cloud Engine blocks outbound traffic on 587, Try using the port 2587.

Related

Send Email From Application Hosted On Local Server

I have orangescrum installed on both local server and cloud server. When I try to send E-mail to other user from local server the mail is not getting delivered. I have checked the SMTP configurations, all seems fine. I checked email track delivery on cpanel but no email is shown.
I want mail server hosted on cloud to accept those emails originated from my local server and send it to the destination email address. It seems like something is blocking the request. Should I have to configure(DKIM,SPF etc) anything on cpanel so that it accept my mails? Any help is much appreciated.
Looks like you want to use your cpanel server as "smarthost" for your local server.
In cPanel you can do it in this way:
You can add the IP address/hostname of the local server (public IP) to the
following options in "WHM Home » Service Configuration » Exim
Configuration Manager":
"Trusted SMTP IP addresses"
"Backup MX hosts"
In some cases you may need to add the IP address to the
/etc/alwaysrelay file and enable Antirelayd.

fail2ban configure third-party email server

I'm using fail2ban on Google Compute Engine where I can't install sendmail or other email servers and I would to set sendgrid as email server.
In jail.local there is this config:
destemail = myemail#myhost.it
mta = mail
Where can I set the host, user, password to send emails via sendgrid.com?
I think that fail2ban uses the machine mail command to send email, thus it is using the machine mailing daemon. If you look at this snippet:
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = printf %%b "Hi,\n
The jail <name> has been started successfully.\n
Regards,\n
Fail2Ban"|mail -s "[Fail2Ban] <name>: started on <fq-hostname>" <dest>
that is taken from here (fail2ban sources on github), you can see that a message of fail2ban is piped to the mail command (in Debian based distribution this is installed via the mailutils package). Since I think your problem is that you cannot use or configure this mail command (which means configuring the mail server), you may think to write a very simple mail binary (in the language you prefer), with a pretty similar interface that may use something like the Gmail App Script to send the email, or even Gunmail or Sendgrid to actually send an email from that machine (with a POST request through the REST Api? Do they allow you?), and add this custom binary to the $PATH of the user that runs fail2ban.
Edit: There is a page in the Google compute documentation related to Send Grid. Also according to this you cannot use sendmail: the ports are closed.
Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to. In addition, having a trusted third-party provider such as SendGrid, Mailgun, or Mailjet relieves Compute Engine and you from maintaining IP reputation with your receivers.

Telnet works but email doesn't

I'm setting up an Alfresco AWS instance and trying to configure inbound email.
As per the documentation I've configured it, hosted the Alfresco mail server on port 1025, set up an iptable rule to forward port 25 --> 1025, set up an folder in Alfresco with the alias 'dropoff' and added my work email as an allowed user for sending emails. I've also ensured all the ports are open on the EC2 instance
So far so good. If I test everything from my local computer with telnet:
helo mywork.com
mail from:myname#mywork.com
rcpt to:dropoff#alfresco.mywork.com
data
From: adinihan#mywork.com
Subject: test mail from command line
this is test number 1
sent from linux box
.
Then it works. I look in the Alfresco folder and there's the test email document. However, if I use Gmail and sign into myname#mywork.com and send an email through Gmail, then it doesn't work. It sends alright and there's nothing in Alfresco logging, however the document just never appears in the Alfresco folder. The from/to address is the same as the telnet command's one.
Since I can telnet from my local computer to the instance I assume it's not an issue with ports on the EC2 instance. Why would telnet work but sending it via Gmail not?
EDIT: got an email back from Google about an hour after I sent it with the error message TLS Negotiation failed: generic::failed_precondition: starttls error (0): protocol error
EDIT 2: here are my inbound emai settings in the global properties file
# Inbound #
email.inbound.unknownUser=anonymous
email.inbound.enabled=true
email.server.enabled=true
email.server.hideTLS=false
email.server.enableTLS=true
email.server.requireTLS=false
email.server.port=1025
email.server.domain=alfresco.amritmro.com
imap.server.enabled=true
imap.server.port=1143
imap.server.host=0.0.0.0

Send mail via CMD console

Hi i want to send mail via microsoft cmd console. I tried many way, but i didnt succeed.
i tried this article http://jpsoft.com/help/index.htm?sendmail.htm
sendmail "bob#bob.com bcc:joe#joe.com" Test Hello!
the error is :
'sendmail' is not recognized as an internal or external command operable program or batch file
and
this article : http://www.brighthub.com/office/collaboration/articles/21840.aspx#imgn_1
c:\>"c:\program files\microsoft office\office12\outlook.exe" /c ipm.note /m someone#gmail.com /a "c:\logs\logfile.txt"
the error is :
the process can not access the file because it is being used by another proccess
but it didnt worked. i dont know where is the problem or what is the problem.
thanks for your advice.
Scenario:
Your domain: mydomain.com
Domain you wish to send to: theirdomain.com
1. Determine the mail server you're sending to.
Open a CMD prompt
Type
NSLOOKUP
set q=mx
theirdomain.com
Response:
Non-authoritative answer:
theirdomain.com MX preference = 50, mail exchanger = mail.theirdomain.com
Nslookup_big
EDIT
Be sure to type exit to terminate NSLOOKUP.
2. Connect to their mail server
SMTP communicates over port 25. We will now try to use TELNET to connect to their mail server "mail.theirdomain.com"
Open a CMD prompt
TELNET MAIL.THEIRDOMAIN.COM 25
You should see something like this as a response:
220 mx.google.com ESMTP 6si6253627yxg.6
Be aware that different servers will come up with different greetings but you should get SOMETHING. If nothing comes up at this point there are 2 possible problems. Port 25 is being blocked at your firewall, or their server is not responding. Try a different domain, if that works then it's not you.
3. Send an Email
Now, use simple SMTP commands to send a test email. This is very important, you CANNOT use the backspace key, it will work onscreen but not be interpreted correctly. You have to type these commands perfectly.
ehlo mydomain.com
mail from:<martin9700#mydomain.com>
rcpt to:<recipient#theirdomain.com>
data
This is a test, please do not respond
.
quit
So, what does that all mean?
EHLO - introduce yourself to the mail server HELO can also be used but EHLO tells the server to use the extended command set (not that we're using that).
MAIL FROM - who's sending the email. Make sure to place this is the greater than/less than brackets as many email servers will require this (Postini).
RCPT TO - who you're sending it to. Again you need to use the brackets. See Step #4 on how to test relaying mail!
DATA - tells the SMTP server that what follows is the body of your email. Make sure to hit "Enter" at the end.
. - the period alone on the line tells the SMTP server you're all done with the data portion and it's clear to send the email.
quit - exits the TELNET session.
4. Test SMTP relay
Testing SMTP relay is very easy, and simply requires a small change to the above commands. See below:
ehlo mydomain.com
mail from:<martin9700#mydomain.com>
rcpt to:<recipient#someotherdomain.com>
data
This is a test, please do not respond
.
quit
See the difference? On the RCPT TO line, we're sending to a domain that is not controlled by the SMTP server we're sending to. You will get an immediate error is SMTP relay is turned off. If you're able to continue and send an email, then relay is allowed by that server.
Unless you want to talk to an SMTP server directly via telnet you'd use commandline mailers like blat:
blat -to you#example.com -f me#example.net -s "mail subject" ^
-server smtp.example.net -body "message text"
or bmail:
bmail -s smtp.example.net -t you#example.com -f me#example.net -h ^
-a "mail subject" -b "message text"
You could also write your own mailer in VBScript or PowerShell.
From Linux you can use 'swaks' which is available as an official packages on many distros including Debian/Ubuntu and Redhat/CentOS on EPEL:
swaks -f you#example.net -t someone#example.com \
--server mail.example.com
A couple more command-line mailer programs:
mailsend
Mail Alert Simple Mailer
Both support SSL too.

Gmail emails do not arrive to my GCloud CE

I have seen that emails do not arrive to my VM instance in GCloud (CE). I tried Hotmail and they did arrive.
Yes I can send from my server with SparkPostMail to Gmail, but from Gmail to the server back they do not arrive, but according to Gmail it was sent well.
Is there any solution?
Is solved:
I use VestaCP in the GCE, and the problem was that my server did not have read permissions in the SSL:
2018-02-08 16:21:02 TLS error on connection from mail-qt0-f180.google.com
[209.85.216.180] (cert/key setup: cert=/usr/local/vesta/ssl/certificate.crt
key=/usr/local/vesta/ssl/certificate.key): Error while reading file. 2018-02-08
16:28:04 Start queue run: pid=25729
What I did was put 644 permissions and that was fixed, and I get emails from Gmail.