How can I make a "html" link instead of the addres

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Wed May 05, 2004 3:44 am

For that you´ll need to send your email as html, instead of plain text email!
See how you can do it!
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Wed May 05, 2004 9:17 am

Example (sendmail.php):

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Sending email...</title>
</head>
<body>
  <table width="100%">
    <tr>
      <td>     
      <?php

      if (isset($_POST["name"]) and isset($_POST["emailad"])){
 
      $name = $_POST["name"];
      $email = $_POST["emailad"];
      $to = "$name <$email>";

      $link = '';
      for ($i=1;$i<=6;$i++){
           $link .= "<a href=\"http://...PlannerSetup.part$i.rar\">Download $i</a>\n";
      }

       // Defining your header information!!

      $headers  = "MIME-Version: 1.0\r\n";
      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
      $headers .= "Content-Transfer-Encoding: 7bit\r\n";   
      $headers .= "From: Yoursite <you@yoursite.com>\r\n";

      // Your html message!!

      $message = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
     <html>
     <head>
     <title>HTML Mail test</title>
     </head>
     <body>
     <table width="100%">
         <tr>
           <td>Download here: <br />' . $link . '</td>
         </tr>
     </table>
     </body>
     </html>';

     // Now let´s send it!

     $ok = mail($to, 'Download request', $message, $headers);

     // Check if it went or not !

     $ok ? echo 'Email sent!' : echo 'Error sending email!';

      }
      else{
          echo 'Please enter name & email!';
      }

    ?>
    </td>
  </tr>
</table>
</body>
</html>
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Wed May 05, 2004 11:01 am

By the way, there's no way to send someone a link to a file without them being able to find out where the file is located.
Image

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Wed May 05, 2004 12:00 pm

Yeh that´s true!
I think he was talking about the complete link url, thing that happens when sending some link in a plain text email.
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests