soundasleep / html2text

A PHP component to convert HTML into a plain text format
MIT License
475 stars 135 forks source link

Causes failure with AWS SES when sending RAW email with attachments #68

Closed aalqadri closed 2 years ago

aalqadri commented 5 years ago

Works great with AWS SES as long as you don't have attachments and must send email as RAW. When email is sent as RAW, text causes delivery failure.

soundasleep commented 5 years ago

Can you provide more information...? It sounds like a configuration or setup problem on your side. html2text is intended to work on HTML ONLY, not on e.g. MIME

aalqadri commented 5 years ago

The library converts the HTML body of the email to text as expected. However, when attempting to send the email with an attachment, SES requires the email to be sent as RAW, and that causes delivery failure due to the error: smtp; 501 Syntax error - line too long

soundasleep commented 5 years ago

Can you provide any more information, such as your setup, the emails you are trying to send, how you're connecting to SES?

aalqadri commented 5 years ago

We're using this library: https://github.com/daniel-zahariev/php-aws-ses As long the email doesn't have an attachment, the email is sent with no issues, when an attachment is added, SES accepts the email and returns a message ID. However, we receive a delivery failure few seconds later with the above error message.

soundasleep commented 5 years ago

Thank you - how are you using html2text with that library? From what I can see that library doesn't depend on html2text directly.

aalqadri commented 5 years ago

When sending an email, you have the option to send the html email as a text for older email clients that don't view html. Since our html emails are dynamically generated, we are converting the html to text and pass the html string and the text string to the library above. Currently I'm using another html2txt library and it is working with no issues.