Send Base64 Image to Email

1

I'm trying to send an email with a base64 image. The html is however going the image not.

An example of how the message is mounted:

<p>Mensagem.</p><br><br><img style='max-height:200px; max-width: 700px; width:auto; height:auto;' src='data:image/jpeg;base64,/Base64DaMinhaImagem' alt='Não foi possível carregar a imagem'>

But the picture is not going to go away, and not even her 'Alt' is appearing. If I try to play what the variable returns me and generate a manual html with it is appearing the image correctly. I'm trying to send to an account in gmail and to an outlook.

    
asked by anonymous 18.08.2017 / 13:59

1 answer

1

¬¬

The inbox of other people is sacred.

Let me repeat it again, now with emphasis. Other people's inbox is sacred .

I do not think I've been clear enough yet.

THE ENTRY BOX OF THE OTHER PEOPLE IS SACRED!

If you host an image somewhere and send an email with the image address in html, you have sent a string. With UTF coding this gives no more than six bytes per character, so even a long URL will not even weigh a kilobyte in the user's inbox.

But if you send a 10-megabyte image encoded as base64, it's as if you had sent a 10-megabyte attachment in the email. If every email image was encoded like this, there would not be enough storage in the world to save all the inboxes.

Depending on one's morals and upbringing, an image encoded as a base64 in an email can be seen as a gaffe, an offense, or even an attack. I was educated to think it's a police case.

For this reason, support for multiple base64 email clients - not just GMail, but also Yahoo! and others - has varied over the years. So if you use this technique, your results will vary. You will never be sure it will work, and when you do, you will not be sure if it will continue to work the next day. For online customers, an image shown today may no longer appear in a few months.

So if you want to continue sending automatic email with image, host your images somewhere. In addition to being better for the user is more quiet for you to maintain.

    
18.08.2017 / 14:20