Images broken in Emails


(Michael Downey) #5

If your server is behind a firewall, the only way an email client will be able to load them is if the network connection is able to access the server.

This is the unfortunate reality of HTML email.


(Jared Needell) #6

That’s not try because the links are broken in the emails and I can access the forums from this computer. Google Apps puts some sort of CDN link in front of the image urls and Google can’t talk to my discourse server.

Why isn’t discourse emails setup properly to attach images to emails rather than using links from a server that’s behind a firewall.

If this is something that can’t be fixed by the Discourse team, what are my options? I already moved files to s3, can I setup my server to put avatars in s3 as well?


(Jared Needell) #7

or can we disable Avatars in emails?


(Michael Downey) #8

Because inline images in HTML emails are not sent as attachments, they’re sent as <img src="..."> references that must be addressable network resources. Doing such might be possible (?) but it is by no means would be a standard solution.

Google might have a way to avoid caching in their clients; I’m not sure but some searching would turn up a method if it exists.


(Jared Needell) #9

So switching to S3 will fix the actually files but not the avatars?


(Michael Downey) #10

I would imagine so, but remember, if you’re storing things on S3, those are publicly available, so you should consider the security risk if your internal server hosting something sensitive (particularly topic attachments!).

I think Discourse caches all profile photos, even those served up by Gravatar, so not sure how you could resolve that other than by using a different email client. :slight_smile:


(Jared Needell) #11

Yeah I’m aware of those risks, I’ll have to bring it up with the rest of my team to see if we need to consider killing off file uploads.

There is an option to disable caching uploaded avatars but my issue is the letter avatars that are default. Can discourse provide any insight on disabling avatars in emails or assistance with getting avatars working?


(Michael Downey) #12

Is your external system avatars enabled site setting enabled? I don’t use this myself so can’t say exactly how it works, but I’d assumed that would load the letter-based avatars from some external CDN that Discourse.org runs…


(Michael Downey) #13

A quick Google search came up with this result; which I assume you’ve already read and tried?

"Set up an image URL proxy whitelist"
https://support.google.com/a/answer/3299041?hl=en


(Jared Needell) #14

I actually haven’t, I’ll check this out thanks.

As for the external system, I do have it checked but the URL is still an internal link URL.


(Kane York) #15

Right, by default for self-installs it sets the letter avatar urls to /letter_avatar_proxy which nginx proxies to avatars.discourse.org so that the server IP is revealed instead of all your visitors’. (Though note that the IPs are not stored or logged anyways.)

You can switch by changing the url format to replace /letter_avatar_proxy/ with https://avatars.discourse.org/ .


(Jared Needell) #16

I updated the url format and the avatars in emails are still trying to download the avatar image from my server rather than discourse.


(Jared Needell) #17

The Avatar proxy still doesn’t seem to be working when I change it to avatars.discourse.org


(Jared Needell) #18

If there could be an option to disable the avatars in the emails, that would fix this issue too.


(Jared Needell) #19

Is there an update on this?

It’s annoying that custom avatars uploaded don’t show up in emails since Discourse is behind a firewall.


(Rafael dos Santos Silva) #20

I had a Discourse behind a firewall, but our users emails were behind the same firewall, so everything woked just fine.

You have a peculiar case, where Discourse itself is in a “safe place” but you send this safe content to the internet over e-mails. Looks like a good use case for Secure Email Mode.


(Jared Needell) #21

I’m ok if content is in the email, I just either want the Avatars fixed or hidden if they cant be fixed.


(Rafael dos Santos Silva) #22

How would you fix that?

You could develop a plugin to base64 encode every image into the email body (I had to do this in another job) but that would be in your plugin, I don’t see this going into core.


(Jared Needell) #23

I have an S3 setup for attachments, why not include avatars? Or allow us to edit the templates of these emails.


#24

I’m curious to hear what kind of workarounds everyone ended up with for this issue. I’m facing the same problem with our intranet Discourse which is running on a DNS name that doesn’t exist outside our corporate network, and it means all the image links in the emails Discourse sends are broken for mobile users without an active VPN connection.

The main annoyance is the lack of Discourse emoji, I am thinking a potential solution could be to rewrite them to Unicode emoji in email notifications?
Or perhaps to be able to define a separate discourse hostname to use inside HTML email, then we could have a static web facing server that hosts the emoji and avatar images. As a kludge, I am thinking of configuring a simple SMTP relay that rewrites the hostname before forwarding it to our Exchange server…
I don’t think I will be allowed to make the primary Discourse host face the open web unfortunately :frowning: