Google Compute Engine won't send emails with links - email

Recently I moved my site to GCE and now emails are not being sent. I send them using gmail's smtp server, through the port 465.
A simple google search points to this article, in which they say that I must use a third party solution like SendGrid.
The weird thing is, I can send regular emails. I was testing my site and I am able to send a simple email with "Hello world" in the message body. But the moment I add a link (URL address) to the body message, the email is not sent.
Is this an expected behaviour? Is there a work around?
I think it's dumb for Google to not allow sending emails even though its own Gmail servers.

Perhaps there is some confusion here. "Despite" of what they say...
Look at their article on Sending Email from an Instance and I quote:
"Google Compute Engine does not allow outbound connections on ports
25, 465, and 587 but you can still set up your instances to send mail
through ports 587 and 465 using servers provided through partner
services, such as SendGrid."
They clearly state that you CAN do it.
Also, if you're authenticating with your Google Account to send via smtp.gmail.com, you're authenticating with a username and password just like any standard email client would. So why would that not be allowed? You're basically connecting as an email client.
On another note, your issues with links were related to the quality of the message therefore being marked as spam (GCE wasn't causing any problems.) by Gmail, as I suspected in my previous comment. You're mainly using Gmail here, and not really any issues directly related to GCE.
I hope this clarifies things a little.

Apparently Google Cloud (despite of what they claim) does allow smtp traffic. I added the firewall exception of the port tcp:465 for all IP addresses.
Additionally, emails containing links were being sent to the spam box, but just on my email account. I sent it to another account and it worked just fine.
[Edit]
GCE had nothing to do with the links problem. It was the poor design of my email content that caused it to go to the spam folder.
The solution was already there. Open the right firewall ports and you're good to go.

Related

Is it possible to use mailgun.com as a SMTP server for personal outgoing emails, including the correct error return emails?

I am using mailgun.com for occassional mass-mailings. Would it be possible to also use it for sending personal emails from me and my wife? The specific problem is that email errors (e.g. "Recipient not found on the server") are only available in the mailgun console and I'd like for them to be received as an error emails sent back to the sender (as is the case with "standard" personal email services). Is it possible to set this up at mailgun.com?
Alternatively, is there a cheap (or even free) SMTP server available for sending emails from the custom domain I own?
(Note that RECEIVING emails to our domain is not a problem, we have that solved using email redirection on my domain.)
Detailed explanation of our setup and reasoning: Behind the scenes, we are both using personail gmail accounts (e.g. me#gmail.com and wife#gmail.com) but we don't advertise these anywhere and our "public" email addresses are me#mydomain.com and wife#mydomain.com. Mydomain.com uses Cloudflare email redirection to redirect our incoming emails back to our Gmail inboxes. We used "Send mail as" GMail feature to send emails as "me#mydomain.com" and "wife#mydomain.com" through smtp.gmail.com but this solution requires us to have "Less secure apps" enabled on our Google accounts and Google seems to be phasing this solution out. The fact that our "real" Gmail addresses are visible in the email headers is not a problem for us.
Originally, we've used free "legacy" Google Workspace accounts on mydomain.com but those are now also being phased out by Google. So we are looking for a SMTP server.
Answering my own question:
I have found that smtp2go.com (which provides very similar services to mailgun.com) provides this option. Your SMTP account can be configured (in the "Advanced" tab) so that bounced email reports are delivered back to the sender's mailbox (or to different mailbox). Additionally, smtp2go's services are free if you send less than 1000 emails monthly so this seems like perfect solution to my problem.

Inbound Email in Github Enterprise

I keep seeing references to Inbound email in GitHub Enterprise online. I manage a Github Enterprise instance running v2.4.1. Nowhere I can find a place to configure that. I see the usual 'Email' settings in the management console, but that only has settings for outbound email.
My users are requesting the ability to reply to PRs or comments from their email and have that response posted directly to the relevant page on the internal Github website. Is this possible?
Responding to my original question. After looking around and raising a ticket with github support, I figured that to make this work I will need to punch a hole through our company firewall. Since I can't do that, I came up with an alternative. I have made my solution available on Github: https://github.com/wrecker/github-mda
Solution
Github Enterprise sends out notification emails with the reply-to address set to reply+NN..NN#reply.[hostname]. Here [hostname] is the FQDN of the GHE instance. E.g: github.priv.mycompany.net.
Create DNS records for reply.github.priv.mycompany.net with your DNS provider.
You will at the minimum need MX records for this sub-domain.
Set up email delivery to reply.github.priv.mycompany.net with an external email provider (Google Apps, Zoho, Exchange Online or roll your own)
Use fetchmail to retrieve messages
When fetchmail downloads new emails it forwards them to a custom MDA. The MDA then filters messages that have a TO address of the form reply+NN..NN#reply.[hostname] and delivers them to the SMTP server on the GHE instance.
So the mail settings on the console window are for both outbound AND inbound mail.
The only other thing that needs to be done to get email reply to work is that you need an MX record in your DNS for the reply, like
reply.<hostname>
Also, you may need to make sure that your SMTP server/relay can contact port 25 on your GHE instance. Depending on firewalls where you work, your mileage may vary.

Send email from server without SMTP enabled

I have written a couple of web sites that contain a "contact us" form.
However, our host recently switched SMTP off. Their excuse is "security issues".
The solution they offer is that they implemented rules whereby all mail generated from the platforms must be sent using the sendmail/phpmail functions and pass through a mail relay which checks the mails and their content and ensures malicious content and activity is completely blocked and they recommend I use "A virtual or dedicated solution".
I have no idea what it is they want me to do to get emailing working again and this is quite urgent as many clients are not getting their emails.
Is there an easy way to go around this in order to get emailing working again?
Many thanks in advance
It generally means that you will have to specify the new mail server they are providing instead of localhost in your code. Further, earlier, you were able to send the mail without authenticating but now on, you must have an account and you must authenticate before you send the mail. (I am not sure though, may be they allow relay to their own servers and you might not need authentication).
Go to the control panel of your hosting account and check for the mail panel. Check out the new smtp server name there and code your site to use this smtp server with credentials. This will let you send mail again.

Can the underlying email provider be determined from an email address?

We are building a system that is, effectively, an email/calendar/contact client.
Users will provide us with their email address password (or other auth, eg oauth) and we will connect to their underlying email system.
"underlying systems" include:
Microsoft Exchange / Office365
GMail
Yahoo Mail
Apple email
Generic IMAP
Each of these systems have subtle (and not so subtle) differences in their APIs, especially to access calendar & contact data. Thus we need to know what provider the user is using.
But we would rather not ASK the user. We would like to figure it out (and at, least reduce the choices) automatically.
I've looked around for something that already implements this but have not found anything. I know it's mostly possible because Windows Phone does it pretty well (just enter username/pw and it does the right thing).
Before I dive in and start writing my own I want to ensure I'm not wasting my time if someone's already done it in an excellent way.
Know of anything like this? For this project prefer C#/.NET.
[EDIT: Adding potential algo]
Potential Algorithm:
Given email address & password
Extract domain name from email address
Try Exchange autodiscover. If successful done.
Use DNS MX records to find smtp host.
Do SMTP EHLO
Gmail responds with "250-mx.google.com at your service"
So if we see a "google.com" we are done.
Yahoo responds with 250-mta1257.mail.sk1.yahoo.com
So if we see a "yahoo.com" in the response we are done.
Apple responds with 250-xxxxxx-mac.com
So if we see a "mac.com" in the response we are done.
If none of the above
IMAP?
...
[EDIT: 5/18]
I built a prototype that uses methods that don't require auth (e.g. just MX/SMTP sluthing). Give it a try: http://bit.ly/KLZKxD
Algorithm seems reasonable. You will get best results running from unfiltered server (meaning it has direct SMTP outbound / doesn't run through a proxy). If running from client (mobile/tablet/desktop), then no guarantees as some ISP's pass SMTP through a proxy relay hence EHLO response is only for proxy.
You may want to do a port check for servers to verify expected protocol support (just a TCP connect may be sufficient but protocol handshake is preferable). Additionally, best to build up a database of verified SMTP and IMAP server mappings as there can be split names (e.g. smtp.domain.com and mail.domain.com) - discovering SMTP is easy, discovering outbound server(s) which usually also means calendar/contacts server, not so much (except for Exchange but only if autodiscovery is configured correctly).
If you can get your users to approve and assuming you have their username/password, you could try connecting to SMTP via MX record and sending an email back to your own address then checking through headers for useful info about the server (needs to be authenticated to relay). Users could alternatively reply to an email you generate in order to get the same server info.
Also ensure that you do your own DNS query and try each MX record or all primaries -- if the principal MX is down or DNS is poorly configured for equal weighting, you could end up hitting a smarthost / backup which may just be a dumb SMTP relay / store-and-forward and not give you the correct response.
TL;DR: No quick solution but a cascaded algorithm that trys and fails different solutions until one works / gives an expected result should work.
Most devices can auto detect the service by parsing the Whole e-mail address. Xyz#gmail.com would obviously be a gmail account. So for Apple, Gmail, Yahoo, Live, Hotmail etc you can easily program for.
For other domains, including custom, you can try this: http://www.exclamationsoft.com/exclamationsoft/netmailbot/help/website/HowToFindTheSMTPMailServerForAnEmailAddress.html
You can detect Google Apps For Your Domain accounts by examining the domain's MX records. If the primary MX record is ASPMX.L.GOOGLE.com, then it's GMail.
I created an implementation of this that has been used widely with some success: https://github.com/tig/Email2Calendar
This is used by both milelogr.com and freebusy.io.

send email using dns server

Am developing and newsletter email software in vb.net for a friend, and he has asked me to add option to send email using dns servers,
How do i send an emai using dns server without smtp or imap?
Send email "using DNS servers" still uses SMTP. And it's generally a bad idea. Here's what it's about:
Usually, an email app (your own, Outlook, etc.) send mail using SMTP or similar protocol to a configured mail server. It could be a company's own server, or an ISP's server, or something like that. The mail may pass through various outgoing mail servers on its way out of an organisation, but at some point it hits a "boundary server" (There are pretty names for all these different types of server, but they're not important right now.)
This boundary server uses DNS to find the recipient's mail server and then sends the message (using SMTP) to that server. (I have omitted the details on purpose)
Sending email "using DNS" means that your app acts as a boundary server. It uses DNS to find the recipient's mail server and then sends the mail directly - rather than using any outgoing servers.
It's a bad idea for two reasons.
More and more ISPs block SMTP traffic that doesn't pass through their outgoing servers
More and more incoming servers validate the boundary server using various techniques. Your app is not likely to be accepted by these servers
Both of these issues are anti-spam countermeasures, so using this technique makes you look like a spammer, leaves many of your messages blocked, and is likely to get your IP address blacklisted.
Hopefully you can explain this to your friend so that they will understand that the "normal" way of sending mail is the only way to ensure that they don't get listed as a spammer.