I'm looking to run a mail server on a Google Compute Engine instance, and have discovered Google's blockage of port 25, 465, and 587. I'll probably use Mailjet for outgoing mail. Anyone found a good solution for incoming mail?
Email messages sent to your app are implemented as HTTP requests containing MIME data. To process incoming email messages, you associate email addresses with script handlers in your app configuration, then include the handlers in your app's code.
The link below is for python but there is no restriction on language.
https://cloud.google.com/appengine/docs/standard/python/mail/receiving-mail-with-mail-api
Related
I am trying to send mail from a compute instance using Gmail's smptp relay and I have enabled smtp-relay through my GSuite account and have also configured POSTFIX in my compute instance and as per mail.log file the mail has been delivered but it is not appearing in my Gmail box. Could you please let me know what is being missed?
Here is the log for the same.
At first, have a look at the Firewall rules overview where at section Always blocked traffic you can find that:
Google Cloud always blocks the traffic that is described in the
following table. Your firewall rules cannot be used to allow any of
this traffic:
So, you should follow documentation Choosing an email service to use:
To use a G Suite domain: Follow the instructions for SMTP relay
service settings in the G Suite documentation. SMTP relaying through G
Suite is only allowed through ports 465 or 587.Port 25 is not
supported through G Suite.
and use ports 465 or 587 to connect to G Suite.
Also have a look at this guide SMTP relay: Route outgoing non-Gmail messages through Google:
In the Allowed senders section, select the users who are allowed to
send messages through the SMTP relay service:
Only registered Apps users in my domain—The sender must be a registered user in one of your domains.
Only addresses in my domains—The sender doesn't have to be a recognized G Suite user, but must be in one of your registered
domains. This can be useful when you have third-party or custom
applications that need to send messages.
Any addresses (not recommended)—The sender address can be anything, even an address outside of your domain.
Important: The Any addresses option makes you more vulnerable to abuse,
either through malware on your user’s machines or by
misconfiguration of your SMTP infrastructure. Therefore, we don't
recommend this option.
and check who is allowed to send emails, then follow next step:
In the Authentication section, check one or both boxes to set an authentication method:
Only accept mail from the specified IP addresses—The system only accepts mail sent from these IP addresses as coming from your domains.
Require SMTP Authentication—Enforces the use of SMTP authentication to identify the sending domain. Using this option
requires your clients to connect via TLS.
and check if you use whitelisted your instances.
In addition, this example could be useful to check your steps.
In case if you still have an issue, check possible alternatives SendGrid:
This tutorial shows how to use SendGrid to send email from an app
running on a Compute Engine instance. SendGrid is a third-party email
service that offers Compute Engine users a free trial with 12,000
transactional emails free each month.
or Mailgun, or Mailjet. If they work for you, but you still need G Suite you can contact G Suite Support. It they don't work for you also - you should check you Postfix configuration first.
While migrating from AWS EC2 instances to Google Compute Engine instances we got problems with sending emails via SMTP (Sendgrid).
I read a lot about it and read that the ports (587, 462, 25) of SMTP are blocked... And to read this article.
https://cloud.google.com/compute/docs/tutorials/sending-mail/#sending_mail_through_corporate_mail_servers
Questions:
For my understanding we should open a Cloud Launcher of SendGrid?
If (1) = yes, then I see it (the cloud launcher) does not support C# and our code today of sending emails is based on C#. So that we will have to change the code to one of those: Node.js, Python, Ruby, Go & PHP?
Is there any way to unblock this outbound connections on port 587 (or 462, 25)? Without Cloud Launcher.
Thanks in advance
1) Yes, if you want to use it through google. If not I recommend directly going to one of the smtp providers such as sendgrid, spakpost, mandrill... to get and account and use their smtp service to send mail.
2) You can use C# by simply not using the Cloud Launcher and purchasing an account directly from the vendor and usning their SMTP service.
3) No, port 2525 is free to send outbound emails to smtp providers through GCP so I highly recommend using that since it can be used for sendgrid as well.
Current Setup
I use Google Apps for personal / non-transactional emails. MX records for my domain point to google.
I have a dedicated IP for my LAMP server, and the SMTP port is available. I use cPanel to manage the server. I have created an email account through cPanel.
Goal
I want to use my host's native SMTP for sending transactional emails. I cannot use Google Apps SMTP because of per-day limit. These transactional emails need neither be saved in sent items nor replies to such emails be monitored.
Problem Area
I am not able to send transactional mails using host's native SMTP (not able to set this up, so no errors yet!)
Q1. Is the goal (using both host's native SMTP and Google Apps)
achievable? Looking at this and this, I believe it should be.
Q2. If yes, how should I setup in my cPanel? Please let me know if more [relevant] information about server setup is required to answer this.
Q1: Yes.
Q2: Same as if you were setting it up without Google Apps. Sending mail does not require any special setup. If you are still having difficulty, you need to check with your provider or ask the question of a cpanel expert -- the problem is unrelated to Google Apps.
What you didn't ask but need to know:
Cannot deliver email to Google Apps address; Gmail receives the same email fine
Why can't my server send outgoing email?
I was wondering if anyone might be able to explain to me why it's taking nearly 30 seconds each time my Java web app sends an email using Gmail's SMTP server? See the following timestamps:
13/04/2010-22:24:27:281 DEBUG test.service.impl.SynchronousEmailService - Before sending mail.
13/04/2010-22:24:52:625 DEBUG test.service.impl.SynchronousEmailService - After sending mail.
I'm using spring's JavaMailSender class with the following settings:
email.host=smtp.gmail.com
email.username=myaccount#gmail.com
email.password=mypassword
email.port=465
mail.smtp.auth.required=true
Note that the mail is getting sent and I'm receiving it fine, there's just this delay which is resulting in a slow experience for the application user.
If you know how I can diagnose the problem myself that would be good too :)
It might be that gmail uses this delay to prevent spammers from using their SMTP server from the "outside": if the SMTP is called from the actual webmail client it would not use this delay.
In order to test this, you could open a telnet session to port 25 and do a manual SMTP session
(Search the web for SMTP HELO for examples)
GMail uses SSL for connection. To validate SSL certificate properly certain time is needed. Exact time depends on complexity of the certificate chain and use and accessibility of CRLs and OCSP checking. It's very likely that Java checks OCSPs for the certificate(s) presented, and this can be slow.
Try running your application on different system (preferably in other subnet) to exclude influence of firewalls. Maybe some part of communication (either SMTP itself, or CRL retrieval or OCSP checking) is slowed down by the firewall.
Depending on your OS, you should have a proper mail system that takes care of actually sending mails outside your network.
For instance, Postfix can do the job nicely. The configuration of Postfix would be on another thread, but typically Postfix would accept mails from your LAN (accepting to be a relay for your LAN) and would transfer the mails to gmail.
This is a exemple as to how setup postfix to have gmail as relay.
Having a mail service taking care of the relay of Gmail mails allows your Java application to be freed almost instantly (Postfix absorbs the mail, store it in its queue and forward it to Gmail itself).
I am trying to setup windows server 2008 smtp server to relay emails to gmail smtp. Everything appears to be setup but it is not sending emails. Could you please help me figure out whats wrong.
Below is the setup:
Windows server 2008 with SMTP server
feature installed. Need SMTP server
to forward all messages to gmail smtp
server to send.
I have google apps setup for my
domain, also I can send emails
throught my test app using
gmail smtp.
SMTP Server Configuration: By default has default smtp server virtual directory.
In Properties of that virtual smtp server changed following.
Fully qualified domain name = mydomain.com
smart host = smtp.gmail.com
TCP Port = 587
Out Bound Security = Basic Authentication(my username password for google apps email account)
In domains list under virtual smtp server. I have one default domain that's server dns. I added another one for my domain name.
With above setup i am trying to redirect all email to gmail smtp.
I tested connection to smtp.gmail.com from server on port 587 through telnet and it works.
I am trying to use above server from my web application also by just dropping emails in pickup directory. It get's picked up and also accepts request form web application but never sends an email.
I can see that it adds those emails in queue folder but it stays there forever.
When i try to send emails from web app to above server it rejects if To address is other than my domain.(Am i missing something in list of domains)
Thanks for all answers, finally found solution there is a property for maximum sessions which value was 0 by default. Changed it to 100 and it send all pending emails immediately.
Possible reasons are that some SMTP servers block the outgoing messages if there domain name mismatch, possible to prevent spam mails from being sent. So for example, I will not be able to send my email with an address abc#mydomain.com from my domain yourdomain.com.
Hope that helps.
Ensure your sending domain is the same as the google apps domain
Ensure your sending address is a real address and not just an alias
IIRC you need to use STARTTLS (SSL) not basic authentication
This souds like a DNS issue. Check your /badmail directory. It will have .bad and .bdp files in there. You can open these in notepad (there will be some binary in there).
However, it may point to the possible problem.
You may also want to try and enable logging on the SMTP service. There may be something in there.