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

Download link in Email

the mail() function

Moderators: macek, egami, gesf

Download link in Email

Postby blank81 » Fri Jan 20, 2012 12:28 am

Hi everyone,
im new in PHP and i have some issue here. i try to send an email with download link below is my code:
$adminmail="xxx@abc.com.my";
$adminmail2="zzz@abc.com.my";
$headers="From:abc@abc.com\n";
$headers.="Cc:abcd@abc.com\r\n";
$subject="new download\n\n ";
$message.="Name:new download\n";
$message.="Attachement: http://www.abc.com.my/file/upload/$new_file_name\n";


based on above code, i will get an email as below:

Name:new download
Attachment: http://www.abc.com.my/file/upload/newfilename

and i can download the file with the link. but what i wanna do is i want the link is hidden as below:

Name:new download
Attachment: download here


please advice and thanks
blank81
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jan 20, 2012 12:17 am

Re: Download link in Email

Postby TheProdigyGuy » Fri Jan 20, 2012 3:16 pm

Code: Select all
<?php
$adminmail="xxx@abc.com.my";
$adminmail2="zzz@abc.com.my";
$headers='MIME-Version: 1.0' .PHP_EOL;
$headers .='Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
$headers.="From:abc@abc.com\n";
$headers.="Cc:abcd@abc.com\r\n";
$subject="new download\n\n ";
$message="Name:new download\n";
$new_file_name="myfile.rar";
$message.=
'<a href="http://www.abc.com.my/file/upload/' . $new_file_name . '">' . 'Download It</a>' . PHP_EOL;
@mail(yourstuffgoeshere);
?>
TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Re: Download link in Email

Postby blank81 » Fri Jan 20, 2012 6:14 pm

Hi TheProdigyGuy,
thanks for your replied, i did change my code but when i get the notification its still display the link, not hiding under the download it. Below is the result after i use your code:

Name:new download
Attachment: <a href="http://www.abc.com.my/file/upload/7932Document1.pdf">Download It</a>


Please advice.
Thanks
blank81
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jan 20, 2012 12:17 am

Re: Download link in Email

Postby TheProdigyGuy » Sat Jan 21, 2012 12:02 pm

You are Welcome blank81)
s the result after i use your code:

Name:new download
Attachment: <a href="http://www.abc.com.my/file/upload/7932Document1.pdf">Download It</a>

IMHO you have missed again properly $headers.

Code: Select all
<?php
$adminmail="xxx@abc.com.my";
$adminmail2="zzz@abc.com.my";

$headers='MIME-Version: 1.0' .PHP_EOL;
$headers .='Content-type: text/html; charset=iso-8859-1' . PHP_EOL;

Code: Select all
$headers.="From:abc@abc.com\n";
$headers.="Cc:abcd@abc.com\r\n";
$subject="new download\n\n ";
$message="Name:new download\n";
$new_file_name="myfile.rar";
$message.=
'<a href="http://www.abc.com.my/file/upload/' . $new_file_name . '">' . 'Download It</a>' . PHP_EOL;
@mail(yourstuffgoeshere);
?>


Did you try that exact code which i posted above?(I resposted it again *See the red lines*)
Also note that:(Especially if you are using some mail client programs for 'fetch' mails from inbox such as Thunderbird,The BAT,Outlook etc.) that mail programs can force HTML tags to look like as plaintext.
So if you are using such client programs check settings(Message Body AS Original HTML not plaintext in this case)
It shuld work for you (i retested it on my localhost webserver and i'm getting HTML formatted mails as well)

Cheers.
TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm


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.