Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts

    mail with attachment problems

    Hi. I have the following code:
    Code:
    else if(file_exists("site".$timp.".zip"))
    	{$file=fopen("site".$timp.".zip", "rb");
    	$data=fread($file, filesize("site".$timp.".zip"));
    	fclose($file);
    	$data=chunk_split(base64_encode($data));
    	$message.="Content-Type:{\"application/octet-stream\"};\n"."name=\"site".$timp.".zip\"\n"."Content-Disposition: attachment;\n"."filename=\"site".$timp.".zip\"\n"."Content-Transfer-Encoding: base64\n\n".$data."\n\n";
    	$message.="--{{$mime_boundary}\n";
    	unset($data);
    	unset($file);
    	if(mail($to, $subject, $message, $headers))
    		{header("Location: comanda_primita.html");}
    The problem with it is, there is no attachment. Instead, at the end of the mail I get:
    --==Multipart_Boundary_x1074db4782f70d7323f462617b73ab9dx
    Content-Type:{"application/octet-stream"};
    name="site1256892830.zip"
    Content-Disposition: attachment;
    filename="site1256892830.zip"
    Content-Transfer-Encoding: base64

    UEsHCFBLAwQUAAAACAC5Vl47UnvYAEYJAACNUgAAFAAAADEyNTY4OTI4MzB1cGxvYWQucGhw7Rtr
    b9w28vMGyH/QCQayRrIbr5M0qR0l9ebWhQHbCWpfcLnaEGgt18urXpW4iV3D//2GD2lJkdL6dYe0
    x7RxreHMcGY4Lz769n0+zx8/KvDvC1Lgvh/FqCyHGJWXf5B8CGP++vbjR2uUJHkAP3Cff8JYkOJv
    3gTw/rX3CUCzrMAomvfXwt29/cmRh0pvbUZKgov1x496V2TWJ2W4yOMMTfE0nJEY9+X4r09okocp
    SvCT03WG3LtayxGdB3zSYY0lMLYZQpJ9xauZPfM4n3VOwkQevEPT6S7HFgPX10KXwbsyjwnlQ35J
    KPaHYnJ/CKP+M+/VBv8jTJEFfpljPL0Mi8U0i2c/XaJ5lg2jLPHZ+KzIksD/ZTg4OuD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fWkz540EZSZ9aEnLDklfWZ1TiDrNvqUr
    bDp9cJtO2yT9od2mKwTlNn1gScsOSV/rGz5DIkvp6yh+ZlJTWShHBb320rZaIyiTYZs+b2y7QFMr
    oxbey8RqSey1FcW6JppVsa0oVjVRkaDt9CNFX8XeyqV0l9JdSncp3aX07zilt23x+E5DolfbktOt
    9nMAI0dqNola0ni7WbrKjOS3TJCtORytyDo2Ic2kcz8plynHfkzcKo0tOrpF8do4aMHRGhurtFke
    CnTu+tsVMgPj7qbVwqItKqI6LG4cFVEVFnaeM5K2nKnrXD1ARDHWmANIHq/PMZriogT7F1kCOOxG
    U1xl4oSEBUqnQTJ91RfXwfxONIFfw7OM+/Jl4AfBwSKmEHkFDccSGl5cLemvLzg/MRGTMD3YO5gM
    PsOshF1rjoYbsEpDn91Z4pQOjiG+t7ykYvo8IRd4us1R6llP/CtdjusTX79nPZ6T0oN/keA0YKw8
    OeqR1GMyeDOWKSgYjDEfDAyeplgU+srneYxIuu1Fc1SAkUEYUmaDN29e/TgYnfg6ERignOFiMEmj
    bErS8y3v9RmRM9ar5vPvbe2cxyqNOOdhd+AhviAlLY0b7NGGL10CBSN+rcCwg1mW49R+3e0XZ/za
    v7c2RRQFM0hV0z6neuaxnyX5w3pRzp2hN4virMQCX+ESzRfpbyG/aO+foRL/8DLEzAKAycYFraKt
    ZuSrEx/lQBqB92bp8yyimA5KCoIlJ/618AR26w+GN8Rq2P/vpMwzQOKOhihF0TwBuODBZL4hH8s6
    CrXkSjKllsvY09fRvpC9RVpiKu2hfNeW/DZnTxS6FnsDfkfVmSLNKIpD8TICBxs86wkW+tDb0Rv5
    wEFkoxUOpczBZunwJo6p+BNrWm7hUnIiSWn4Vc3tRq6lN0wP5F1cQljlB3ExO7Nb+pmuZrurwZ+m
    ty1Bmol1L9I/n5prh9W1q3igYA09HVl6Sp356Efhh3I3D374E3u/wtz1mVe9pIHfpILwm6xV6sMH
    WVFxwXqsyjHF19LY7EEIOCaq/HL2rQD5+5IKRmRl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AAAACAC5Vl47UnvYAEYJ
    AACNUgAAFAAAAAAAAAAAACAAAAAEAAAAMTI1Njg5MjgzMHVwbG9hZC5waHBQSwECAAAUAAAACAC5
    Vl47pKJIyu4JAAAkJQAAGwAAAAAAAAAAACAAAACICQAAMTI1Njg5MjgzMGNsYXNzLmVhc3l6aXAu
    cGhwUEsFBgAAAAACAAIAiwAAALsTAAAiAENvbXByZXNzZWQvU3BsaXR0ZWQgYnkgUEhQIEVhc3la
    SVA=


    --{==Multipart_Boundary_x1074db4782f70d7323f462617b73ab9dx
    Does anyone know what's wrong with the code? Thank you in advance.

    PS: This script also sends multiple attachments (if there are multiple files)...But since it doesn't send even one attachment....

  • #2
    New Coder
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I forgot to copy this part of the code:
    Code:
    $headers="From: $from";
    $semi_rand=md5(time());
    $mime_boundary="==Multipart_Boundary_x{$semi_rand}x";
    $header.="\nMIME-Version: 1.0\n"."Content-Type: multipart/mixed;\n"."boundary=\"{$mime_boundary}\"";
    So if you were thinking that the headers weren't set...they were...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •