Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

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

the mail() function

Moderators: macek, egami, gesf

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

Postby Leo_1 » Wed May 05, 2004 12:00 am

Hi all,
I want to send an email with a link, but when I do so everyone can see were are the files located and that is something that I don't want. I want them to just see a link like this Dowlaod.

This is my code and isn't working.
Code: Select all

<html>
<head>
<Title>Planner download</Title>
</head>
<body>

<?php
if (isset($_POST["name"]) and isset($_POST["emailad"]))
{
  $name=$_POST["name"];
  $email=$_POST["emailad"];
  for ($i=1;$i<=6;$i++)
   $download[$i]= "<a href=\"http://........./........./PlannerSetup.part$i.rar\">Download $i</a>";
  if (mail($email, "Download request",
           "Name:$name \nEmail address:$email\nDownload here:
           \n$download[1]\n$download[2]\n$download[3]\n$download[4]\n$download[5]\n$download[6]"))
  {
  echo "Email sent!";
  @mail("myemail@hotmail.com", "pldownload","Name:$name \nEmail address:$email");

  }
  else
  {
    echo "Email not sent!! Try again";
    @mail("myemail@hotmail.com", "Failed!!!","Name:$name \nEmail address:$email");
  } 
}

?>
</body>
</html>

Leo_1
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Apr 29, 2004 4:17 am
Location: Holland

Postby gesf » 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!
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Leo_1 » Wed May 05, 2004 4:40 am

Hi,

I read the site, but it didn't help me that much. The problem remains. You may have an example of it.

Thanks
Leo_1
New php-forum User
New php-forum User
 
Posts: 4
Joined: Thu Apr 29, 2004 4:17 am
Location: Holland

Postby gesf » 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>
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby swirlee » 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.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby gesf » 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.
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.