mailto link that adds text to email body.

G

Guest

Hi,

I would like to know if this is possible:

- visitor clicks on mailto link
- visitor's email client opens
- to/subject/body of mail populate with my pre entered info

the body part is filled with some questions, or for example sth to complete.

This is to avoid using a form. Appart from that this way the visitor can send me an
attachment if needed.

thanks a lot,

Alfredo
 
A

Andrew Murray

the syntax for that is

<a href="mailto:[email protected]&subject=yoursubject&body=yourmessage">Click here
to email</a>

This puts the &subject string in the subject line of their email client, and the
&body string as the first line of the message.

The drawback is the "&body= bit only allows a limited amount of text (i.e. the
first line of the message) - not the way you describe, with pre-written
questions.

I don't see a way around that, unless there are other parameters preceding with
"&" that can be added on but I don't believe so.

Why not use a form? The mailto tag is an open invitation to spam email bots
these days. Forms are a 'safer' way to collect information as you're wanting to
do (but can still attract spam), you can use the 'file' field type to
attach/upload documents (if your ISP supports that server extension feature.)
 
R

Ronx

<a href="mailto:[email protected]&subject=yoursubject&body=yourmessage">Click
here to email</a>
should be
<a href="mailto:[email protected]?subject=yoursubject&body=yourmessage">Click
here to email</a>
You will be limited to a total of 256 characters for the entire link. Any
spaces after the ? should be replaced with + e.g message+body+is+here,
otherwise the recipient may see message%20body%20is%20here.
mailto links do not work in all browsers/email clients.

Ron
 
G

Guest

Ronx said:
<a href="mailto:[email protected]&subject=yoursubject&body=yourmessage">Click
here to email</a>
should be
<a href="mailto:[email protected]?subject=yoursubject&body=yourmessage">Click
here to email</a>
You will be limited to a total of 256 characters for the entire link. Any
spaces after the ? should be replaced with + e.g message+body+is+here,
otherwise the recipient may see message%20body%20is%20here.
mailto links do not work in all browsers/email clients.

Note that to avoid harnessing by spam bots, you should always protect your
mailto links by generating them through some javascript, like:

<script type="text/javascript" language="Javascript"><!--
var e='yoursite';e='you'+'@'+e+'.com';
var subject='your subject';
var body='your small text body';
document.write('<a href="mailto:'+e+'?subject='+urlencode(subject)+
'&body='+urlencode(body)+'">Click here to email</a>');
//--></script><noscript>(email address protected against spam robots, please
enable Javascript to view it)</noscript>

Of course, it's best to use forms processed by your own web server in order
to send emails to an hidden address. Note however that the form processor
will run on your server.
If it processes the form to send an actual email, the web server itself will
be the sender. Be careful to check that the form processor cannot be used by
spammers to send emails to random users, or your website will be tracked as
an unsafe relay, and considered as the spammer source.

Today, it's often simpler to install a online forum or BBS, stored and
managed completely by your web server, and where you can even include a
private section, where users can write privately.

If you don't want your users to create an online account to write you, then
use a simple contact form that stores messages on the web server files space
(create a protected administration page to consult these messages and manage
your replies and clean up old messages).

If you don't want to use web storage for these messages, use a separate
email address for your contacts through this form, and prepare your email
client to receive these messages sent only by your web form processor (don't
reveal this email address anywhere, use a long and complex email address
hidden in the script source of the web form processor).
 

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

Top