Download link in Email

the mail() function

Moderators: egami, macek, gesf

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

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

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/7932D ... ">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.

Post Reply