473,487 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is this a safe way to e-mail?

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>

Jul 7 '06 #1
5 1356
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:a@b.com?Body=<?php echo urlencode($comment_data)
?>">send</a>

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

regards,
-ad

FP wrote:
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>
Jul 7 '06 #2
FP
admataz wrote:
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:a@b.com?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?

Jul 7 '06 #3
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 8 '06 #4
FP said the following on 7/7/2006 12:10 PM:
admataz wrote:
<snip>
><a href="mailto:a@b.com?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?
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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 8 '06 #5
admataz wrote:
[...]
Make sure you urlencode the string and that will deal with any
characters or line breaks.

example for php:

<a href="mailto:a@b.com?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:aa@bb.com?body=Happy+birthday!

Partial URL encoding (space bar should not be mandatory to encode):
mailto:aa@bb.com?body=Hello,%0a%0aHappy birthday!

Full URL encoded:
mailto:aa@bb.com?body=Hello,%0a%0aHappy%20birthday %21

--
Bart

Jul 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
2540
by: Irmen de Jong | last post by:
Pickle and marshal are not safe. They can do harmful things if fed maliciously constructed data. That is a pity, because marshal is fast. I need a fast and safe (secure) marshaler. Is xdrlib the...
11
2224
by: dee | last post by:
OleDbCommand class like many .NET classes has the following description in its help file: "Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for...
0
7696
by: gm | last post by:
Immediately after generating the Access application from the Source Safe project I get: "-2147467259 Could not use ''; file already in use." If Access database closed and then reopened I get:...
3
2517
by: tcomer | last post by:
Hello! I'm working on an asynchronous network application that uses multiple threads to do it's work. I have a ChatClient class that handles the basic functionality of connecting to a server and...
15
2733
by: Laser Lu | last post by:
I was often noted by Thread Safety declarations when I was reading .NET Framework Class Library documents in MSDN. The declaration is usually described as 'Any public static (Shared in Visual...
1
3564
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
1
4587
by: jecheney | last post by:
Hi, Im currently using the following code for reading/writing to a network socket. private StreamReader clientStreamReader; private StreamWriter clientStreamWriter; .... TcpClient tcpClient...
4
1901
by: George2 | last post by:
Hello everyone, Here is Bjarne's exception safe sample, http://www.research.att.com/~bs/3rd_safe.pdf template <class Tclass Safe {
44
7736
by: climber.cui | last post by:
Hi all, Does anyone have experience on the thread-safty issue with malloc()? Some people said this function provided in stdlib.h is not thread- safe, but someone said it is thread safe. Is it...
3
1509
by: =?Utf-8?B?anBhdHJjaWs=?= | last post by:
Don't see any official notice that compiled library dll's loaded in the BIN directory of an asp.net website need to be thread safe, but concurrent visits to the same web site sure bear this out....
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.