base64 decoding im Mailanhang

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • base64 decoding im Mailanhang

    servus gemeinde,

    ich hab folgendes problem:

    ich hab ein skript für ein emailformular mit anhang erstellt. ich bekomme zwar ne mail, in der ist aber noch der base64-code zu sehen.
    php ist nicht gerade meine stärke.
    wo muss denn diese decoder-funktion hin?

    also mein skript bi hierhin:

    Quellcode

    1. function sendApplication( $id )
    2. {
    3. global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid;
    4. $row = new mosJobPosting( $database );
    5. $row->load( $id );
    6. if ( !$row->id )
    7. {
    8. mosRedirect( "$mosConfig_live_site/index.php?option=$option&task=error&msg=" . _JL_NOSUCHJOB );
    9. }
    10. else
    11. {
    12. $tmplvars = get_object_vars( $row );
    13. foreach ( $_REQUEST as $k => $v )
    14. {
    15. $tmplvars["req_$k"] = $v;
    16. }
    17. $tmpl = new mxTemplate( "$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}" );
    18. if ( $tmpl->setTemplate( "applicationemail" ) )
    19. {
    20. // store the file information to variables for easier access
    21. $tmp_name= $_FILES['attach']['tmp_name'];
    22. $type = $_FILES['attach']['type'];
    23. $name = $_FILES['attach']['name'];
    24. $size = $_FILES['attach']['size'];
    25. $error = $_FILES['attach']['error'];
    26. $message = '';
    27. $mime_boundary = '';
    28. $tmpl->setVars( $tmplvars );
    29. $tmpl->parseTemplate();
    30. $message = $tmpl->getOutput();
    31. //echo '<br>--<br> 1.' . $message;
    32. // if the upload succeded, the file will exist
    33. if ( file_exists($tmp_name) )
    34. {
    35. //echo '<br>--<br> 2.' . $message;
    36. // generate a random string to be used as the boundary marker
    37. $mime_boundary = "--==Multipart_Boundary_x".md5(mt_rand())."x";
    38. // check to make sure that it is an uploaded file and not a system file
    39. if( is_uploaded_file($tmp_name) )
    40. {
    41. //echo '<br>--<br> 3.' . $message;
    42. $message .= "nn Attachment : $name";
    43. // open the file for a binary read
    44. $file = fopen( $tmp_name,'rb' );
    45. // read the file content into a variable
    46. $data = fread( $file,filesize($tmp_name) );
    47. // close the file
    48. fclose( $file );
    49. // now we encode it and split it into acceptable length lines
    50. $data = chunk_split( base64_encode($data) );
    51. }
    52. // next, we'll build the message body
    53. // note that we insert two dashes in front of the
    54. // MIME boundary when we use it
    55. $message = "This is a multi-part message in MIME format.\n" . "--{$mime_boundary}\n" .
    56. "Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n" .
    57. "Content-Transfer-Encoding: 8bit\n\n" . $message . "\n\n";
    58. // now we'll insert a boundary to indicate we're starting the attachment
    59. // we have to specify the content type, file name, and disposition as
    60. // an attachment, then add the file content and set another boundary to
    61. // indicate that the end of the file has been reached
    62. if( $data )
    63. {
    64. $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" .
    65. "name=\"{$name}\"\n" .
    66. "Content-Disposition: attachment;\n" .
    67. "filename=\"{$name}\"\n" .
    68. "Content-Transfer-Encoding: base64\n\n" .
    69. $data . "\n\n";
    70. }
    71. $message .= "--{$mime_boundary}--\n";
    72. }
    73. //echo '<br>--<br> <b>4.</b>' . $message;
    74. //$Replyto = '';
    75. // function
    76. //sendEmail( $email, $subject, $message, $fromname, $fromemail, $replyto, $mime_boundary );
    77. sendEmail( $cfgjl['mailfromaddress'], _JL_APPLICATION_SUBJECT, $message, $cfgjl['mailfromname'], $cfgjl['mailfromaddress'], $Replyto, $mime_boundary);
    78. mosRedirect( "$mosConfig_live_site/index.php?option=$option&Itemid=$Itemid&task=thankyou&id=$id" );
    79. }
    80. else
    81. {
    82. showError( _JL_ERRORSETTMPL . ": applicationemail" );
    83. }
    84. }
    85. }
    86. function sendEmail( $email, $subject, $message, $fromname='', $fromemail='', $replyto='', $mime_boundary='')
    87. {
    88. /*if ( function_exists( "mosMail" ) )
    89. {
    90. mosMail($fromemail, $fromname, $email, $subject, $message);
    91. }
    92. else
    93. {*/
    94. // generate a random string to be used as the boundary marker
    95. $headers = "";
    96. if ( trim( $fromemail ) )
    97. {
    98. $headers = "From: $fromname <$fromemail>\r\n";
    99. }
    100. if ( trim( $replyto ) )
    101. {
    102. $headers .= "Reply-To: <$replyto>\r\n";
    103. }
    104. $headers .= "X-Priority: 3\r\n";
    105. $headers .= "X-MSMail-Priority: Low\r\n";
    106. $headers .= "X-Mailer: PHP 4.x \r\n";
    107. if( $mime_boundary )
    108. {
    109. $headers .= "MIME-Version: 1.0\r\n".
    110. "Content-Type: multipart/mixed;\n\t boundary=\"$mime_boundary\"";
    111. }
    112. @mail($email, $subject, $message, $headers);
    113. //}
    114. }
    Alles anzeigen




    danke schon mal im voraus.

    :shock:
  • hab das auch schon andere meinungen einheolt und die meinten, dass das eihentlich funzen sollte.

    hier mal mein formular.... vielleicht hab ich da was übersehen...

    Quellcode

    1. <form action="index2.php" method="POST" name="adminForm" enctype="multipart/form-data">
    2. <input type="hidden" name="id" value="{mxtvalue=id}" />
    3. <input type="hidden" name="reference" value="{mxtvalue=reference}" />
    4. <input type="hidden" name="option" value="{mxtvalue=option}" />
    5. <input type="hidden" name="Itemid" value="{mxtvalue=Itemid}" />
    6. <input type="hidden" name="task" value="send" />
    7. <table cellpadding="5" cellspacing="0" border="0" width="100%" class="contentpane">
    8. <tr>
    9. <td class="contentheading" width="100%" colspan="2">{mxtlang=_JL_APPLYFORJOB}: {mxtvalue=title} <br></td>
    10. </tr>
    11. <tr>
    12. <td><b>{mxtlang=_JL_FIRSTNAME}</b></td>
    13. <td><input type="text" name="firstname" class="inputbox" size="40" value="" /></td>
    14. </tr>
    15. <tr>
    16. <td><b>{mxtlang=_JL_LASTNAME}</b></td>
    17. <td><input type="text" name="lastname" class="inputbox" size="40" value="" /></td>
    18. </tr>
    19. <tr>
    20. <td><b>{mxtlang=_JL_ADDRESS1}</b></td>
    21. <td><input type="text" name="address1" class="inputbox" size="40" value="" /></td>
    22. </tr>
    23. <tr>
    24. <td><b>{mxtlang=_JL_CITY}</b></td>
    25. <td><input type="text" name="city" class="inputbox" size="40" value="" /></td>
    26. </tr>
    27. {mxtshowif=config_useusstate}
    28. <tr>
    29. <td><b>{mxtlang=_JL_STATE}</b></td>
    30. <td>{mxtvalue=usstates}</td>
    31. </tr>
    32. {/mxtshowif}
    33. <tr>
    34. <td><b>{mxtlang=_JL_ZIPCODE}</b></td>
    35. <td><input type="text" name="zipcode" class="inputbox" size="40" value="" /></td>
    36. </tr>
    37. <tr>
    38. <td><b>{mxtlang=_JL_DAYTELEPHONE}</b></td>
    39. <td><input type="text" name="daytelephone" class="inputbox" size="40" value="" /></td>
    40. </tr>
    41. <tr>
    42. <td><b>{mxtlang=_JL_EVENINGTELEPHONE}</b></td>
    43. <td><input type="text" name="eveningtelephone" class="inputbox" size="40" value="" /></td>
    44. </tr>
    45. <tr>
    46. <td><b>{mxtlang=_JL_APPLICANTEMAIL}</b></td>
    47. <td><input type="text" name="email" class="inputbox" size="40" value="" /></td>
    48. </tr>
    49. <tr>
    50. <td valign="top"><b>{mxtlang=_JL_COVER_LETTER}</b></td>
    51. <td><textarea class="inputbox" name="coverletter" id="coverletter" cols="50" rows="10"></textarea></td>
    52. </tr>
    53. <tr>
    54. <td valign="top"><b>Upload</b></td>
    55. <td><input type="file" class="inputbox" name="attach" />
    56. </td>
    57. </tr>
    58. <tr>
    59. <td colspan="2"><input type="submit" name="sendbtn" class="button" value="{mxtlang=_JL_SEND_APPLICATION}"/></td>
    60. </tr>
    61. </table>
    62. </form>
    Alles anzeigen
  • phpmailer ist simpel

    ich würd mal behaupten, dass folgender code zu deiner obigen funktion äquivalent ist (vorausgesetzt er funktioniert)

    Quellcode

    1. global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid;
    2. require("class.phpmailer.php");
    3. $mail = new PHPMailer();
    4. $row = new mosJobPosting( $database );
    5. $row->load( $id );
    6. if(!$row->id) {
    7. mosRedirect( "$mosConfig_live_site/index.php?option=$option&task=error&msg=" . _JL_NOSUCHJOB );
    8. return;
    9. }
    10. $tmplvars = get_object_vars( $row );
    11. foreach ( $_REQUEST as $k => $v ) {
    12. $tmplvars["req_$k"] = $v;
    13. }
    14. $tmpl = new mxTemplate( "$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}" );
    15. if ( !$tmpl->setTemplate( "applicationemail" ) ) {
    16. showError( _JL_ERRORSETTMPL . ": applicationemail" );
    17. return;
    18. }
    19. // store the file information to variables for easier access
    20. $tmp_name= $_FILES['attach']['tmp_name'];
    21. $name = $_FILES['attach']['name'];
    22. $tmpl->setVars( $tmplvars );
    23. $tmpl->parseTemplate();
    24. $message = $tmpl->getOutput();
    25. if ( file_exists($tmp_name) ) {
    26. $mail->AddAttachment($name);
    27. }
    28. $mail->AddAddress("josh@site.com", "Josh Adams");
    29. $mail->From = $cfgjl['mailfromaddress'];
    30. $mail->FromName = $cfgjl['mailfromname'];
    31. $mail->Subject = _JL_APPLICATION_SUBJECT;
    32. $mail->Body = $message;
    33. $mail->Send();
    34. mosRedirect( "$mosConfig_live_site/index.php?option=$option&Itemid=$Itemid&task=thankyou&id=$id" );
    Alles anzeigen


    nicht vergessen die class.phpmailer.php herunterzuladen und zu entpacken