Solved

email Storage Issues in Mysql database

Posted on 2013-05-18
6
227 Views
Last Modified: 2013-05-25
My Email is storing in database as:

<p><a class="mediumimage " href="http://www.website.com/cw4/admin/js/tinyMCE/UserFiles/Images/aliciasilverstone01_1024x768.jpg" target="_blank"><img src="http://www.website.com/cw4/admin/js/tinyMCE/UserFiles/_middle/Images/aliciasilverstone01_1024x768.jpg" alt="" /></a></p>
<p> </p>
<table style="width: 730px; height: 66px;" border="0">
<tbody>
<tr>
<td>Welcome</td>
<td>Jungle</td>
</tr>
<tr>
<td>Dirty</td>
<td>Stars</td>
</tr>
</tbody>
</table>

Open in new window


when email is sent, no matter if its type is HTML, it shows HTML tags there, i am missing something on mysql part i think, anyone can throw some light here

table column Message collation is: utf8_unicode_ci

Table Dump

CREATE TABLE IF NOT EXISTS `mailinglist_messages` (
  `MessageID` bigint(255) unsigned NOT NULL AUTO_INCREMENT,
  `Message` longtext COLLATE utf8_unicode_ci,
  `SentToGroup` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `SentOn` datetime DEFAULT NULL,
  `SentBy` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `InstanceName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`MessageID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;

Open in new window

0
Comment
6 Comments
 
LVL 77

Assisted Solution

by:arnold
arnold earned 114 total points
ID: 39177899
It is unwise as you see to store email directly into a database.  An alternative might be to parse and extract/strip HTML storing only data.
It is best to store emails within the filesystem

Do you parse email?
0
 
LVL 25

Assisted Solution

by:Tomas Helgi Johannsson
Tomas Helgi Johannsson earned 113 total points
ID: 39178334
Hi!

You might want to store the email-message as LONGBLOB instead of LONGTEXT.
By doing that you are storing the message "as is" and will get it back exactly as you stored it.

Regards,
    Tomas Helgi
0
 
LVL 50

Assisted Solution

by:Steve Bink
Steve Bink earned 113 total points
ID: 39179891
arnold is right - storing this type of data in a database field is inefficient, at best.  The file system is a much better alternative, with just a pointer to the file in the database.

As far as the formatting, there is something else in your code escaping the content before its insertion into the database.  MySQL does no translation like that.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 77

Expert Comment

by:arnold
ID: 39179910
Mysql_real_escape_string this is the php code that should be used to avoid sql injection issues with data from forms/external sources.
Not sure what process the incomng emails
0
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 0 total points
ID: 39181047
Thanks for theupdate guys, but nothing worked, i actually had to convert the htmlenteties to html through cffunction and it stored the details in the db without any issue, something else might have been causing an issue
0
 
LVL 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 39196277
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
html input clean up 3 54
PHP loop not working 4 62
mysql joining from the same table 6 42
Help needed with Powershell  XML to MySQL 5 38
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question