Webmaster Key - Discussion Forums


Welcome, Guest. Please login or register.
Did you miss your activation email?
February 09, 2012, 09:59:48 AM

Login with username, password and session length
Welceome to Forums!

Important information for guests and new members:

In order to understand the full benefits of becoming an active member of this forum, please review the following information on guest and new member restrictions. These forum changes have been prompted by an overwhelming and unreasonable amount of bot postings and incoherent guest spam messages. We wish to prevent these events from happening in the future and make our community a more comfortable place for all of our members.

For guests:

Guests are not allowed to open new topics, polls, or posts attachments.
If you wish to open up new discussions on this forum, we encourage you to register.

For new members:

New members with less than five posts are not allowed to modify additional profile information such as avatars, contact information, biographies, and signatures. However, new members are encouraged to post their own topics or reply to topics initiated by other members. Become active on the forums and 5 posts should be an easy task!

We are a diverse community with members from all over the world. We encourage new ideas and interesting conversation. Do not be afraid to post webmaster/computer-related questions or problems, as our active members are always willing to help when they are able. Interested? Join us.

+ Webmaster Key Forums
|-+ Webmaster Corner
| |-+ Site Design and Web Authoring
| | |-+ Text Area to Email
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print
Author Topic: Text Area to Email  (Read 2163 times)
Andy
Administrator
Veteran
*****
Posts: 5 752



« on: February 16, 2008, 09:54:19 AM »

Does anyone know how to preserve line breaks from a form's text area data if the form's action is a mailto: and the text area is supposed to be the body text for an email? When I tried it, the email body ends up with the text but minus any line breaks.

I only want to use HTML and Javascript (client-side code) to solve this.

Any tips appreciated  Smiley
Report to moderator   Logged

SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #1 on: February 16, 2008, 10:25:58 AM »

Andy, can you please show example as because of headache I hardly could understand what you're trying to achieve.
Report to moderator   Logged

Denis
Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #2 on: February 16, 2008, 01:05:32 PM »

It's weird since I thought there was a problem with this technique and just put together an example that 90% works:

Code:
<html>
<head>
<title>Test</title>
</head>
<body>
<form action="mailto:me@hotmail.com" method="get">
<input type="hidden" name="subject" value="enq" />
<textarea rows="8" cols="32" name="body">
Hello,

how are you today?

All the best,

Arnie
</textarea>
<br />
<button type="submit">Send</button>
</form>
</body>
</html>

Some Javascript to remove the + signs in the email body would be all that's required. At least in IE6.

Report to moderator   Logged

SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #3 on: February 17, 2008, 10:25:23 AM »

what about using method="post" instead, as it wouldn't add "+" signs between words like with get and you need to set your enctype to plain/text.
So in the end you'll should get something like this:
Code:
<html>
<head>
<title>Test</title>
</head>
<body>
<form action="mailto:me@domainexample.net" method="post" enctype="text/plain">
<input type="hidden" name="subject" value="enq" />
<textarea rows="8" cols="32" name="body">
Hello,

how are you today?

All the best,

Arnie
</textarea>
<br />
<button type="submit">Send</button>
</form>
</body>
</html>

Would this solution work for you?

Be aware that not all e-mail clients work with this, so such method is less reliable than PHP forms IMHO.
« Last Edit: February 17, 2008, 10:34:01 AM by SensoVision » Report to moderator   Logged

Denis
Andy
Administrator
Veteran
*****
Posts: 5 752



« Reply #4 on: February 17, 2008, 11:19:56 AM »

I solved this problem today. The answer is to use the POST method like you suggested.

The reason I didn't want to use the PHP sendmail function is that the email may get blocked by ISPs and it does nothing to stop your form being used to send you anonymous Spam messages. Also, PHP is required which may not be available to every webmaster.

I created a product around this idea so can't post the actual code I came up with, but it is similar to what you posted.

Quote
Be aware that not all e-mail clients work with this, so such method is less reliable than PHP forms IMHO.

I have sold products based on this idea before and nobody asked for a refund so I am ok so far with compatibility.

Thanks for the tips anyway.
Report to moderator   Logged

SensoVision
Administrator
Veteran
*****
Posts: 5 857


I'm proud user of Debian GNU/Linux OS


WWW
« Reply #5 on: February 17, 2008, 11:29:47 AM »

Quote
I solved this problem today. The answer is to use the POST method like you suggested.
sorry for late response, have been busy yesterday evening, so only replied now.

Quote
The reason I didn't want to use the PHP sendmail function is that the email may get blocked by ISPs and it does nothing to stop your form being used to send you anonymous Spam messages. Also, PHP is required which may not be available to every webmaster.
each method have it's own drawbacks and flaws Smiley

Quote
I have sold products based on this idea before and nobody asked for a refund so I am ok so far with compatibility.
sure, if it's working most of time, than there is no reason to stop using this code.

Quote
Thanks for the tips anyway.
you're always welcome!
Report to moderator   Logged

Denis
Pages: [1] Go Up Stumble Upon! Digg It! del.icio.us! Add to Technorati! ReddIt!  Send this topic Print 
+ Webmaster Key Forums
|-+ Webmaster Corner
| |-+ Site Design and Web Authoring
| | |-+ Text Area to Email

Jump to:  
« previous next »


Our Partners
RelmaxTOP Ranking System Web Hosting RelmaxTOP Ranking System
Staff Sites
12Noon[12Noon Gallery] Andy[Urgentclick]
Tamuril[Tamuril's Digital Art Exhibit] Sensovision
Powered by MySQL Powered by PHP We are hosted by Relmax Inc. |Our Privacy Policy | Sitemap
Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC
Forum design by Tamuril © 2005.
Valid XHTML 1.0! Valid CSS!