Is this a safe way to e-mail?

F

FP

When a user clicks the "E-mail" button I need the contents of a
database comment field in the body of an e-mail. To compensate for
strange characters in the comment field this is the best solution I
could come up with. So far the only downside I can see is that the
body of the e-mail always starts with a space and an equal sign. Aside
from the fact that client e-mailing is unreliable, does my code seem
reasonable or am I out to lunch on this?
I'm using the text area because I couldn't compensate for some of the
double quotes.

<FORM ACTION="mailto:" METHOD="post" enctype="text/plain">
<div id="a" style="display: none">
<P><TEXTAREA NAME=" " ROWS=1 COLS=1 WRAP="virtual">
<? Comment Data Here?>
</TEXTAREA></P>
</div>
<INPUT TYPE=submit VALUE="E-mail">
</Form>
 
A

admataz

hi FP,
the obvious thing to do is to send via your server, but if you can't do
this for some reason you could try appending the body of the text to a
mailto: link as a query string

Make sure you urlencode the string and that will deal with any
characters or line breaks.

example for php:

<a href="mailto:[email protected]?Body=<?php echo urlencode($comment_data)
?>">send</a>

should work for most email clients, but I would test it on all
platforms.

regards,
-ad
 
F

FP

admataz said:
hi FP,
the obvious thing to do is to send via your server, but if you can't do
this for some reason you could try appending the body of the text to a
mailto: link as a query string

Can't send from the server, the button is simply suppose to transfer
the text into a new e-mail message on the users computer



<a href="mailto:[email protected]?Body=<?php echo urlencode($comment_data)
?>">send</a>

should work for most email clients, but I would test it on all
platforms.

Your mailto solution works in the sense that it puts the text into the
body of the e-mail. It even works on the strange characters I've been
testing with however it turns spaces into plus signs.
I'm using OSX 10.3.9 with Mail 1.3.11 for testing. Does "Mail" not
follow internet standards?
 
R

Randy Webb

FP said the following on 7/7/2006 1:31 AM:
When a user clicks the "E-mail" button I need the contents of a
database comment field in the body of an e-mail.

You can't reliably do that on the client.
To compensate for strange characters in the comment field this
is the best solution I could come up with.

It is an unreliable solution though.
So far the only downside I can see is that the body of the e-mail
always starts with a space and an equal sign. Aside from the fact
that client e-mailing is unreliable, does my code seem reasonable
or am I out to lunch on this?

You want something that works "reliably" on something that is inherently
unreliable? Think about it.
I'm using the text area because I couldn't compensate for some of the
double quotes.

<FORM ACTION="mailto:" METHOD="post" enctype="text/plain">

Your statement "client e-mailing is unreliable" shows it's ugly head
with that form for me.
 
R

Randy Webb

FP said the following on 7/7/2006 12:10 PM:
admataz wrote:


Your mailto solution works in the sense that it puts the text into the
body of the e-mail. It even works on the strange characters I've been
testing with however it turns spaces into plus signs.
I'm using OSX 10.3.9 with Mail 1.3.11 for testing. Does "Mail" not
follow internet standards?

What "Internet Standard" are you referring to? There is no "Standard"
with regards to how an OS and/or browser should deal with a mailto: URL
 
B

Bart Van der Donck

admataz said:
[...]
Make sure you urlencode the string and that will deal with any
characters or line breaks.

example for php:

<a href="mailto:[email protected]?Body=<?php echo urlencode($comment_data)
?>">send</a>

should work for most email clients, but I would test it on all
platforms.

A function that URLencodes a space as '+' is no good. Though it may
work on browser URLs, it seems that at least some email clients don't
like it. A safer way is to encode it to '%20'.

Your PHP function:
mailto:[email protected]?body=Happy+birthday!

Partial URL encoding (space bar should not be mandatory to encode):
mailto:[email protected]?body=Hello,%0a%0aHappy birthday!

Full URL encoded:
mailto:[email protected]?body=Hello,%0a%0aHappy%20birthday%21
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top