Page 1 of 1

Mailto Prob

Posted: Sat Aug 30, 2003 2:35 pm
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

Posted: Sat Aug 30, 2003 6:18 pm
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:

Posted: Sat Aug 30, 2003 10:39 pm
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??

Posted: Sun Aug 31, 2003 1:43 am
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.