Mailto Prob

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
leoden
Forum Newbie
Posts: 21
Joined: Sat May 24, 2003 8:48 pm

Mailto Prob

Post by leoden »

Hello

Im currently having a bit of an issue with the mailto function. On my site I have an online catalogue which lists 25 items per page an I want to have a link at the end of each row enabling the user to email details of the item to someone.

Code: Select all

echo "<td><a href=mailto:subject=$Subject&body=$Description>Email this item</a>";
This works fine, however a problem arises as the description for items can be up 300 chars long so the parsed HTML returned will be will have the description twice. This obviously increases the size of each page greatly.

What I wish to have is a php function which is called when the user clicks the link ( being passed the item no ) which then queries the db to get the description and then runs the mailto function. I dont want to use a self made mailling screen.

Any ideas

Leo
User avatar
wmasterj
Forum Commoner
Posts: 40
Joined: Mon Aug 18, 2003 5:52 pm
Location: Stockholm, Sweden

Post by wmasterj »

you could make a little script of your own using the mail() function. So when to user clicks the links he's automaticaly sent to a page whie sends the mail and then returns the user to the orginal page.

http://www.php.net/mail

i use a function which is called whenever needed - it looks somewhat like this( it's simplified):

Code: Select all

<?php
function email($to, $subject, $mailMessage)
{
    //Sends an email of choice to someone, can be used for all types of
    //email notifications that have to be sent.
    
    // - BASIC INFO - 
    $message = '
    <html><head><title></title></head><body>
    <font face="verdana" size="1" color="220000">
    '.$mailMessage.'
    </font>
    </body></html>
    ';
    // - HEADERS -
    $headers  = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "From: ywamse.com STAFF<emailadress@to_be.replied>\n";
    $headers .= "Reply-To: emailadress@to_be.replied\n";
    // - MAILING -
    @$mail = mail($to, $subject, $message, $headers) or die("<font face="verdana" size="1"><h3>Error!</h3><b> « Contact <a href="mailto:emailadress@to_be.replied">webmaster</a></b></font>");
	
}
?>
I hope it helps :wink:
leoden
Forum Newbie
Posts: 21
Joined: Sat May 24, 2003 8:48 pm

Post by leoden »

Cheers 4 the help, but I really need use the mailto function to pop up a mail message with everything filled in except the To address. The user can then add some text to the message body (' Hi soandso thought you might be interested in this item etc etc') and send it off to whoevers interested. I reckon theres some way in javascript to do it??
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Just ideas...

Forward (using the link) the user to email.php, that contains a header...

Code: Select all

// sql code here, fetching your data.
header ("Location:mailto:$values");
...or similiar. This will trigger the 'popup' you wanted. Rewrite to fit your needs.
Post Reply