Email body too long - Mysql text column handles only 64kb #4

Closed
holli opened this Issue Feb 12, 2012 · 1 comment

Comments

Projects
None yet
2 participants

holli commented Feb 12, 2012

We had some complaints that emails were cut off from the middle. After a while of debugging we realized that content column is saved as text. Mysql text takes only 64kb. (http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html)

64kb can be easily reached with a longer html message. And its definitely is reached if you have any attachments.

I guess Postgresql has no limit?

Solutions

Force longtext column in mysql. Change following line to migration
https://github.com/cerebris/mailhopper/blob/master/lib/generators/mailhopper/templates/migrations/create_emails.rb#L19

t.text   :content, :limit => 100.megabytes  # limit is number of characters, not actually bytes

Rails sql handler will use the right columns depending on the sql server. So it should work with Postgresql etc. 100.megabytes is just a random good big number as a limit. We are using utf8 chars in db so 100 megabytes is actually multiplied by three.

Also readme.md could have some info:

Generate default initializer and migration files: `rails generate mailhopper`.
Default max-size for content is quite large. Depending on your needs
and sql server you can modify the migration.

Btw, thanks for the gem, has helped a lot :)

@dgeb dgeb closed this in 0ee42bc Feb 13, 2012

Owner

dgeb commented Feb 13, 2012

Sorry to hear that this gave you trouble. We've only been using mailhopper with relatively small emails, so we hadn't yet encountered this limit.

I agree with your recommendations and implemented them in the latest version of mailhopper: 0.0.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment