viernes, 5 de octubre de 2007

Mandar un email con fichero adjunto

//***************** index.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
include 'mail_attachment.php';

//**** campos: de, para, asunto, mensaje, fichero
mail_attachment("pgarcia@cpo.es", "pgarcia@cpo.es", "subject", "message", 'mail_attachment.php');
?>
</body>
</html>




//***************** mail_attachment.php
<?php
function mail_attachment ($from , $to, $subject, $message, $attachment){
$fileatt = $attachment; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
$fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment

$email_from = $from; // Who the email is from
$email_subject = $subject; // The Subject of the email
$email_txt = $message; // Message that the email has in it

$email_to = $to; // Who the email is to

$headers = "From: ".$email_from;

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$msg_txt="\n\nMail created using free code from 4word systems : http://4wordsystems.com";

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$email_txt .= $msg_txt;

$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_txt . "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";


$ok = @mail($email_to, $email_subject, $email_message, $headers);

if($ok) {
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
}

?>


Ver Enlace original

41 comentarios:

Anónimo dijo...

[u][b]Xrumer[/b][/u]

[b]Xrumer SEO Professionals

As Xrumer experts, we from been using [url=http://www.xrumer-seo.com]Xrumer[/url] fitted a long time conditions and remember how to harness the enormous power of Xrumer and adapt it into a Spondulix machine.

We also yield the cheapest prices on the market. Diverse competitors will charge 2x or square 3x and a lot of the time 5x what we responsibility you. But we feel in providing prominent help at a small affordable rate. The whole incidental of purchasing Xrumer blasts is because it is a cheaper variant to buying Xrumer. So we plan to abide by that bit in recollection and outfit you with the cheapest standing possible.

Not solitary do we have the most successfully prices but our turnaround occasion after your Xrumer posting is wonderful fast. We drive pull someone's leg your posting done before you discern it.

We also cater you with a roundish log of affluent posts on manifold forums. So that you can see for yourself the power of Xrumer and how we be struck by harnessed it to help your site.[/b]


[b]Search Engine Optimization

Using Xrumer you can wish to see thousands upon thousands of backlinks for your site. Tons of the forums that your Install you will be posted on get acute PageRank. Having your link on these sites can categorically expropriate strengthen up some crown grade back links and uncommonly aid your Alexa Rating and Google PageRank rating utterly the roof.

This is making your site more and more popular. And with this developing in reputation as familiarly as PageRank you can keep in view to appreciate your site really filthy high-pitched in those Search Motor Results.
Traffic

The amount of transportation that can be obtained by harnessing the power of Xrumer is enormous. You are publishing your situation to tens of thousands of forums. With our higher packages you may even be publishing your position to HUNDREDS of THOUSANDS of forums. Imagine 1 brief on a all the rage forum disposition inveterately cotton on to a leave 1000 or so views, with say 100 of those people visiting your site. Now create tens of thousands of posts on celebrated forums all getting 1000 views each. Your shipping liking associate through the roof.

These are all targeted visitors that are interested or exotic far your site. Imagine how assorted sales or leads you can succeed in with this colossal loads of targeted visitors. You are in fact stumbling upon a goldmine ready to be picked and profited from.

Reminisce over, Shipping is Money.
[/b]

GO YOUR TWOPENNY DEFAME TODAY:


http://www.xrumer-seo.com

Anónimo dijo...

Infatuation casinos? prefer this advanced [url=http://www.realcazinoz.com]casino[/url] advisor and kidnap up online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also into our additional [url=http://freecasinogames2010.webs.com]casino[/url] guide at http://freecasinogames2010.webs.com and get better ground transpire chary spondulicks !
another in vogue [url=http://www.ttittancasino.com]casino spiele[/url] locality is www.ttittancasino.com , pro german gamblers, parasynthetic in magnanimous online casino bonus.

Anónimo dijo...

LihCtz [url=http://ukbootshopon.com/]cheap ugg boots[/url] WqtBuc http://ukbootshopon.com/

Anónimo dijo...

buy generic viagra viagra buy mastercard - viagra newsletter

Anónimo dijo...

[url=http://loveepicentre.com/faq.php][img]http://loveepicentre.com/uploades/photos/7.jpg[/img][/url]
dating practices in turkey [url=http://loveepicentre.com/taketour.php]is distinct dating a scam[/url] park slope dating
arrin toth dating [url=http://loveepicentre.com/]alexander ludwig dating annasophia[/url] who is orlando bloom dating
rebecca buckley dating [url=http://loveepicentre.com/]pnline dating[/url] is ciara dating 50 cent

Anónimo dijo...

buy tramadol online order tramadol online to florida - tramadol 75 mg

Anónimo dijo...

buy soma online generic name soma compound - soma what drug class

Anónimo dijo...

[url=http://loveepicentre.com/][img]http://loveepicentre.com/uploades/photos/10.jpg[/img][/url]
valerie bertinelli dating [url=http://loveepicentre.com/]free on line dating[/url] pisces male sag female dating tips
free dating women men ebay sex [url=http://loveepicentre.com]players dating[/url] free bbw people community dating site
christian match dating website [url=http://loveepicentre.com/map.php]muslim dating older woman[/url] college dating edu internet student

Anónimo dijo...

buy soma soma yoga definition - erin soma san diego

Anónimo dijo...

soma for sale soma muscle relax er - buy soma airbag

Anónimo dijo...

carisoprodol soma buy soma vanishing back bra - soma watson brand 350 mg 90 tabs

Anónimo dijo...

ebook communicate http://audiobookscollection.co.uk/it/Computer-Vision-ECCV-2008-10-conf-part-3/p135367/ riddle of the stars ebook [url=http://audiobookscollection.co.uk/fr/My-Book-of-Subtraction-Kumon-Workbooks/p214399/]convert imp ebook to ipad[/url] ice haven ebook

Anónimo dijo...

Hi, order zyban - zyban drug http://www.wellbutrinonlinesale.net/#zyban-drug , [url=http://www.wellbutrinonlinesale.net/#buy-zyban-online ]buy zyban online [/url]

Anónimo dijo...

Anti Depressants Migraine Medications cipro no prescription - order cipro online http://www.cheapcipromed.net/#order-cipro-online , [url=http://www.cheapcipromed.net/#cipro-without-rx ]cipro without rx [/url]

Anónimo dijo...

Apc Drug order finasteride online - cheap finasteride 5mg http://www.propeciahowtosave.net/#cheap-finasteride-5mg , [url=http://www.propeciahowtosave.net/#cheap-generic-propecia ]cheap generic propecia [/url]

Anónimo dijo...

cheap cialis order cialis online mastercard - cialis online no prescription

Anónimo dijo...

buy tramadol overnight purchase tramadol - tramadol 93 58 information

Anónimo dijo...

sob purchase gabapentin - gabapentin online pharmacy http://www.neurontinonlinesales.net/#gabapentin-online-pharmacy , [url=http://www.neurontinonlinesales.net/#neurontin-sale ]neurontin sale [/url]

Anónimo dijo...

buy tramadol tramadol 50mg recommended dosage - tramadol 627 recommended dosage

Anónimo dijo...

tramadol online no prescription buy cheap tramadol online - tramadol overnight delivery no rx

Anónimo dijo...

buy carisoprodol carisoprodol soma watson 350 mg - carisoprodol non scheduled drug

Anónimo dijo...

buy cialis online cialis last longer - buy cialis online yahoo

Anónimo dijo...

buy cialis online cialis online new zealand - cialis online pharmacy no prescription

Anónimo dijo...

xanax online xanax side effects sexually - xanax side effects mayo

Anónimo dijo...

buy tramadol online cod overnight order tramadol online sweden - tramadol hcl 50 mg side effects

Anónimo dijo...

20000 :) cheap effexor online - buy effexor without prescription http://www.effexorfastorder.net/#buy-effexor-without-prescription , [url=http://www.effexorfastorder.net/#effexor-pills ]effexor pills [/url]

Anónimo dijo...

http://buytramadolonlinecool.com/#91646 purchase tramadol no prescription - tramadol addiction lawsuits

Anónimo dijo...

aaa!!! Buy Topamax - topamax online no prescription http://www.topamaxbestonline.net/#order-topamax, [url=http://www.topamaxbestonline.net/#order-topamax]Order Topamax[/url]

Anónimo dijo...

buy tramadol order tramadol from usa) - tramadol hcl 50mg narcotic

Anónimo dijo...

03 generic lorazepam - purchase ativan online http://www.ativanonlinenorx.net/#ativan-cost, [url=http://www.ativanonlinenorx.net/#buy-ativan]cheap lorazepam 2mg[/url]

Anónimo dijo...

4, order lasix - furosemide no prescription http://www.lasixordernow.net/#lasix-no-prescription, [url=http://www.lasixordernow.net/#cheap-furosemide]order lasix[/url]

Anónimo dijo...

buy klonopin online zoloft and klonopin side effects - klonopin and alcohol recreationally

Anónimo dijo...

http://www.integrativeonc.org/adminsio/buyklonopinonline/#6817 klonopin 6 mg/day - klonopin .125 wafers

Anónimo dijo...

http://buytramadolonlinecool.com/#73892 legal buy tramadol online usa - buy tramadol no prescription cod

Anónimo dijo...

all, Buy Assignments - http://www.onlinewritinghelp101.com/#buy-assignments, [url=http://www.onlinewritinghelp101.com/#assignments-online]Assignment Solution[/url]

Anónimo dijo...

http://buytramadolonlinecool.com/#30694 tramadol for dogs safe - tramadol hcl headache

Anónimo dijo...

buy klonopin online klonopin migraine - how long does klonopin side effects last

Anónimo dijo...

http://southcarolinaaccidentattorney.com/#51643 carisoprodol erowid vault - buy carisoprodol codeine

Anónimo dijo...

http://southcarolinaaccidentattorney.com/#24975 350mg carisoprodol generic soma - soma generic carisoprodol

Anónimo dijo...

Heya i am for the first time here. I found this board and I find
It truly useful & it helped me out much. I hope to give something back
and help others like you aided me.

My webpage :: book of ra online spielen kostenlos download

Anónimo dijo...

all the time i used to read smaller posts which as well
clear their motive, and that is also happening with this
paragraph which I am reading at this place.

Here is my blog microsoft word