Sabtu, 19 Mei 2012

Siaran Langsung TVONE

Skype! Online Chat  

PHP
Kirim attachment banyak / Multiple file dengan php
Setelah membuat script Untuk kirim Attachment dengan 1 file, lalu bagaimana jika kita akan

mengirim email dengan banyak/ Multiple file.
Berikut script yang dibuat hanya ada beberapa yang perlu di ubah :

 

<?
$adminEmail = "$_POST[adminEmail]";
              
if($_POST['submit']) {
                    
    $to = $_POST['to'];
    $subject = $_POST['subject'];                          
                    
    $pengantar=$_POST[pengantar];
                                        
    $pengantarok =

"Dear&nbsp;&nbsp;".ucfirst(strtolower($_POST['Salutation']))."".ucfirst(strtolower($_POST['Suren

ame'])).",<br><br>";
    $pengantarok2 = "$pengantar<br><br>";
    $pesan = "<table width=700 border=0 cellpadding=0 cellspacing=0 align=center>
        <tr><td height='10'></td></tr>
        <tr><td>$pengantarok</td></tr><tr><td>$pengantarok2</td></tr><tr><td>
    <table width=700 border=0 cellspacing=0 cellpadding=0>
    <tr>
      <td height=25></td>
    </tr>
    </table>
    </td></tr></table>";    
                    
    $attach      = $_FILES['file1']['tmp_name'];
      $attach_type = $_FILES['file1']['type'];
      $attach_name = $_FILES['file1']['name'];

    $countattach = count($attach);
    
      $headers = "From: $adminEmail";


    // Generate string untuk batas (boundary)
    $semi_rand     = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
          
    // Tambahkan header untuk file yang akan dikirim
    $headers .= " MIME-Version: 1.0 " .
          "Content-Type: multipart/mixed; " .
          " boundary="{$mime_boundary}"";
        
    // Tambahkan pesan
    $message .= "--{$mime_boundary} " .
             "Content-Type: text/html; charset="iso-8859-1" " .
             "Content-Transfer-Encoding: 7bit " .
             $pesan . " ";
    $message .= "--{$mime_boundary} ";
                    
    for($i=0;$i<count($attach);$i++){

     // Apabila ada file yang di attach    
    if (is_uploaded_file($attach[$i])) {    
        // Baca file yang akan di attach/kirim ('rb' = read binary)
    $file = fopen($attach[$i],'rb');
    $data = fread($file,filesize($attach[$i]));
    fclose($file);
                    
    // Untuk transisi data gunakan base64_encode();
    $data = chunk_split(base64_encode($data));
                
    // Tambahkan pesan pada file yang dikirim.
    $message .= "Content-Type: {$attach_type[$i]}; " . " name="$attach_name[$i]" " .
        
    "Content-Transfer-Encoding: base64 " . $data . " ";
            
    $message .= "--{$mime_boundary} ";    
                    
    }        
            
    }
 
$body = "$message";
                    
mail($to, $subject, $body, $headers);
                  
echo '<b>Your mail had been send to '.$to.' recipients</b>';


} else {

?>                    
      <form name="letter" action="" method="post" enctype="multipart/form-data">
      <table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td width="23%">Salutation</td>
            <td width="77%"><font size="2" face="Verdana, Arial, Helvetica,

sans-serif"><input type="radio" name="Salutation" value="Mr.">Mr.&nbsp;<input type="radio"

name="Salutation" value="Mrs.">Mrs.</font></td>
          </tr>
          <tr><td colspan="2" height="10"></td></tr>
          <tr>
            <td width="23%">Name To</td>
            <td width="77%"><input name="Surename" type="text" id="Surename" size="35"

style="font-weight:bold" onFocus="this.value='';" value="isi sure name"></td>
          </tr>
          <tr><td colspan="2" height="10"></td></tr>
          <tr>
            <td width="23%">Email To</td>
            <td width="77%"><input name="to" type="text" id="to" size="35"

style="font-weight:bold" onFocus="this.value='';" value="isi to"></td>
          </tr>
          <tr><td colspan="2" height="10"></td></tr>
          <tr>
            <td>Subject</td>
            <td>
            <input name="subject" type="text" id="subject" size="60"

style="font-weight:bold" value=""></td>
          </tr>
          <tr><td colspan="2" height="10"></td></tr>
          <tr>
            <td>From Email</td>
            <td>
            <input name="adminEmail" type="text" id="adminEmail" size="60"

style="font-weight:bold" value=""></td>
          </tr>
          <tr><td colspan="2" height="10"></td></tr>
          <tr>
            <td>Pengantar Kata</td>
            <td><textarea name="pengantar" id="pengantar" rows="15" cols="80"

style="width:50%"></textarea></td>
          </tr>
          <tr><td colspan="2" height="10"></td></tr>
          <tr><td colspan="2" height="10"></td></tr>
        <? for($f=0;$f<20;$f++){ ?>
          <tr>
            <td>Attach File</td>
            <td><input type="file" name="file1[]"></td>
          </tr>
        <? } ?>
          <tr><td colspan="2" height="10"></td></tr>
              <tr>
                <td colspan="2"><input type="submit" name="submit" value="Send Mail"></td>
              </tr>
            </table>
          </form>
<? } ?>


Share |


Raynoch, n.viebliegh@yahoo.cn
15/05/2012 17:05:55
http://www.mycarinsur.com/|car insurance quote yhrk http://www.gettinginsurquotes.com/|free car insurance quotes gsbl
Emmy, adviser8@tecumseh65.org
14/05/2012 15:05:35
http://www.vehicleinsuronline.net/|car insurance qoutes ooafvk http://www.getcompetitivequotes.net/|car insurance quotes 6656
nj car insurance, kundenservice@post.at
14/05/2012 09:05:00
Hi, Oliver.Yes, it's hack for Elgg 1.7.x only.All Elgg hacks for Elgg 1.8.x in the category:But my reply on your response here:Delete Public from Access for Elgg 1.8Open the file:elggenginelibaccess.phpAnd delete this:ACCESS_PUBLIC => elgg_echo("PUBLIC")Have a nice hackday
Marylada, info-ou@ua.ac.be
13/05/2012 14:05:01
http://www.mycarinsur.com/|car insurance quote :-OO http://www.gettinginsurquotes.com/|car insurance quotes hjn
Kassie, admin@tcac.org.au
02/05/2012 19:05:54
http://www.insurerservice.com/|home insurance kcwipq http://www.lifeinsurers4u.com/|life insurance quotes 8DDD
Bonner, daibel@stiarna.com
30/04/2012 15:04:16
http://www.locatemedsfast.com/|propecia %-O http://www.mainmedica.com/|levitra 02345
healthinsurance, a.weaglus@nic.nl
21/04/2012 14:04:51
It only travels to show where there’s will there’s a better way. Keep on trying. – I have bad reflexes. I was once run over by a car being pushed by two guys. – Woody Allen Born 1935
Hayden, info@toequet.com
15/04/2012 11:04:38
Hi, Oliver.Yes, it`s hack for Elgg 1.7.x only.All Elgg hacks for Elgg 1.8.x in the category:But my reply on your rsopsnee here:Delete Public from Access for Elgg 1.8Open the file:elggenginelibaccess.phpAnd delete this:ACCESS_PUBLIC => elgg_echo("PUBLIC")Have a nice hackday
Stephen, reservations@granlibakken.com
12/04/2012 03:04:30
unable to run the script ginivg following error./ocsdiff_conf.php: line 1: ?php: No such file or directory./ocsdiff_conf.php: line 6: =: command not found./ocsdiff_conf.php: line 7: =: command not found./ocsdiff_conf.php: line 8: =: command not found./ocsdiff_conf.php: line 9: =: command not found./ocsdiff_conf.php: line 10: =: command not found./ocsdiff_conf.php: line 11: =: command not found./ocsdiff_conf.php: line 12: syntax error near unexpected token `( ./ocsdiff_conf.php: line 12: `$domains = array(
mxovoyti, vdurtu@mpwafu.com
14/12/2011 23:12:46
M5GT2f , [url=http://ypdupcjeawql.com/]ypdupcjeawql[/url], [link=http://uvydyfzgkfqe.com/]uvydyfzgkfqe[/link], http://euhisjnkqyyq.com/
mmxxifogajv, hzvrxp@acbuhq.com
14/12/2011 22:12:12
O28G0e , [url=http://azzjutcjidcz.com/]azzjutcjidcz[/url], [link=http://fpeuullbioai.com/]fpeuullbioai[/link], http://rrtgtjnozzpm.com/
ulnbqz, xaoilt@nvxrph.com
14/12/2011 02:12:49
WghnOI eaufwbotqjjd
mlegzvlu, ukphbk@iyehap.com
14/12/2011 01:12:48
HM2O8L frupchfbfrrw
Essence, 434@www.nak-nordhorn.de
13/12/2011 21:12:39
That iingsht would have saved us a lot of effort early on.
Trisha, canmen@inspire.net.nz
13/12/2011 18:12:55
That`s a smart answer to a diffcilut question.
toko bunga, frizzy@bungarawabelong.com
17/09/2011 07:09:13
mantaff infonya rek, ini berguna bangett untuk kirim email dari toko bunga ke client

Add Your Comment
Name
Email Address
Website / URL
Message
Mak [600] Karakter
Verify code




Sign up for PayPal and start accepting credit card payments instantly.

copyright © 2004 - 2010 All Rights Reserved, Web Development - iman@imanmaulana.com Telp : (+6221) 91697901, (+62-815) 8778104