cosmic_sniper Posted April 23, 2012 Share Posted April 23, 2012 How can I keep the alignment of the table when the data is pasted on an email? The output of the table is intended to be copied and pasted on an email on an external sever (e.g. yahoo, gmail). The problem is whenever the output is pasted on the body of email, it is distorted. It loses rows and column separations. I am thinking of two ways to solve this (I don't know if these are possible.) Apply some formatting to the table so that it would maintain it's alignment. Use a code to make the output show directly to the body of a third party email service. If the second option is possible, then it would be very great since the whole table intended to be sent through email is a separate file that is displayed using include(). Is there a way to achieve such a thing? I hope I explained my idea clearly. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/ Share on other sites More sharing options...
colleyboy Posted May 3, 2012 Share Posted May 3, 2012 When writing HTML into an email in Yahoo, Gmail etc it is very important to make sure you have the widths and lengths written in the <TABLE> tag and <TD> tag. Worse case scenario use a piece on inline css to format it. Example: (Without CSS) <table cellspacing="0" cellpadding="0" width="500" align="center"> <tr> <td width="250"><p>Cell 1</p></td> <td width="250"><p>Cell 2</p></td> </tr> </table> Example: (With inline css) <table cellspacing="0" cellpadding="0" width="500" align="center"> <tr> <td style="width:250px;"><p>Cell 1</p></td> <td style="width:250px;"><p>Cell 2</p></td> </tr> </table> Hope this helps. Ian Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/#findComment-1342797 Share on other sites More sharing options...
cosmic_sniper Posted May 4, 2012 Author Share Posted May 4, 2012 When writing HTML into an email in Yahoo, Gmail etc it is very important to make sure you have the widths and lengths written in the <TABLE> tag and <TD> tag. Worse case scenario use a piece on inline css to format it. Thanks for the response. It's nice that you pointed that out but I think (I'm not sure though) that would be applicable only if I would encode the output directly on the email. What I'm looking for is some sort of code that would allow users to copy-paste the output as it is (with the alignment) or better yet, a code that would directly email the output. One option might be the use of mail() but if I got it right, using that, the body of the email could only contain up to 70 characters which is a great limitation on my part. Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/#findComment-1343046 Share on other sites More sharing options...
colleyboy Posted May 7, 2012 Share Posted May 7, 2012 Oh, I see! You want to make a script to send a HTML document to an email. Hmm in that case the best thing to do is use the PHPMail but have a preset .html page which is ready to send out. That way you could send the headers to the PHP Mail form sending it out and do it this way. In order to customise the email you would customise the html file. Is this what your looking for? Ian Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/#findComment-1343828 Share on other sites More sharing options...
Jessica Posted May 7, 2012 Share Posted May 7, 2012 If they must copy and paste, I'd assume that copying and pasting a version of the table with the explicit inline css would be best. Did you try that? All email clients are different, you won't be able to ensure it works 100%. Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/#findComment-1343839 Share on other sites More sharing options...
cosmic_sniper Posted May 8, 2012 Author Share Posted May 8, 2012 If they must copy and paste, I'd assume that copying and pasting a version of the table with the explicit inline css would be best. Did you try that? All email clients are different, you won't be able to ensure it works 100%. I'm not so familiar with CSS but I'm formatting the table using attributes on every HTML tag. Oh, I see! You want to make a script to send a HTML document to an email. Hmm in that case the best thing to do is use the PHPMail but have a preset .html page which is ready to send out. That way you could send the headers to the PHP Mail form sending it out and do it this way. In order to customise the email you would customise the html file. Is this what your looking for? You mean using include() as a body of mail()? Did I get it right? Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/#findComment-1343894 Share on other sites More sharing options...
cosmic_sniper Posted May 10, 2012 Author Share Posted May 10, 2012 colleyboy, or do you refer to PHPMailer? Quote Link to comment https://forums.phpfreaks.com/topic/261491-keeping-table-alignment-when-pasting-on-email/#findComment-1344415 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.