ron.deida
Threadersteller
Dabei seit: 06.03.2006
Ort: Regensburg
Alter: 43
Geschlecht:
|
Verfasst Mo 30.10.2006 14:00
Titel Mail-Versand / Attachment Enconding, base64 |
|
|
servus gemeinde,
ich bin verzweifelt...
ich hab so ein skript zusammen gebastel, was emails mit anhängen verschicken soll. nun hab ich es soweit modifiziert, dass ich eine email mit allen relevanten inhalten bekomme, nur der anhang.
der anhang hat immernoch base64-code.
kennt jemand ein skript, dass den code entschlüsselt? hier soweit das skript:
Code: | function sendApplication( $id )
{
global $database, $mosConfig_absolute_path, $mosConfig_live_site, $option, $cfgjl, $mainframe, $my, $Itemid;
$row = new mosJobPosting( $database );
$row->load( $id );
if ( !$row->id )
{
mosRedirect( "$mosConfig_live_site/index.php?option=$option&task=error&msg=" . _JL_NOSUCHJOB );
}
else
{
$tmplvars = get_object_vars( $row );
foreach ( $_REQUEST as $k => $v )
{
$tmplvars["req_$k"] = $v;
}
$tmpl = new mxTemplate( "$mosConfig_absolute_path/components/com_jobline/templates/{$cfgjl['template']}" );
if ( $tmpl->setTemplate( "applicationemail" ) )
{
// store the file information to variables for easier access
$tmp_name= $_FILES['attach']['tmp_name'];
$type = $_FILES['attach']['type'];
$name = $_FILES['attach']['name'];
$size = $_FILES['attach']['size'];
$error = $_FILES['attach']['error'];
$message = '';
$mime_boundary = '';
$tmpl->setVars( $tmplvars );
$tmpl->parseTemplate();
$message = $tmpl->getOutput();
//echo '<br>--<br> 1.' . $message;
// if the upload succeded, the file will exist
if ( file_exists($tmp_name) )
{
//echo '<br>--<br> 2.' . $message;
// generate a random string to be used as the boundary marker
$mime_boundary = "--==Multipart_Boundary_x".md5(mt_rand())."x";
// check to make sure that it is an uploaded file and not a system file
if( is_uploaded_file($tmp_name) )
{
//echo '<br>--<br> 3.' . $message;
$message .= "nn Attachment : $name";
// open the file for a binary read
$file = fopen( $tmp_name,'rb' );
// read the file content into a variable
$data = fread( $file,filesize($tmp_name) );
// close the file
fclose( $file );
// now we encode it and split it into acceptable length lines
$data = chunk_split( base64_encode($data) );
}
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n" . "--{$mime_boundary}\n" .
"Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 8bit\n\n" . $message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
if( $data )
{
$message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" .
"name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
"filename=\"{$name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
$message .= "--{$mime_boundary}--\n";
}
//echo '<br>--<br> <b>4.</b>' . $message;
//$Replyto = '';
// function
//sendEmail( $email, $subject, $message, $fromname, $fromemail, $replyto, $mime_boundary );
sendEmail( $cfgjl['mailfromaddress'], _JL_APPLICATION_SUBJECT, $message, $cfgjl['mailfromname'], $cfgjl['mailfromaddress'], $Replyto, $mime_boundary);
mosRedirect( "$mosConfig_live_site/index.php?option=$option&Itemid=$Itemid&task=thankyou&id=$id" );
}
else
{
showError( _JL_ERRORSETTMPL . ": applicationemail" );
}
}
} |
und jetzt noch das send-email
Code: | function sendEmail( $email, $subject, $message, $fromname='', $fromemail='', $replyto='', $mime_boundary='')
{
/*if ( function_exists( "mosMail" ) )
{
mosMail($fromemail, $fromname, $email, $subject, $message);
}
else
{*/
// generate a random string to be used as the boundary marker
$headers = "";
if ( trim( $fromemail ) )
{
$headers = "From: $fromname <$fromemail>\r\n";
}
if ( trim( $replyto ) )
{
$headers .= "Reply-To: <$replyto>\r\n";
}
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Low\r\n";
$headers .= "X-Mailer: PHP 4.x \r\n";
if( $mime_boundary )
{
$headers .= "MIME-Version: 1.0\r\n".
"Content-Type: multipart/mixed;\n\t boundary=\"$mime_boundary\"";
}
@mail($email, $subject, $message, $headers);
//}
} |
help. i need somebody...
// topic bearbeitet | dastef
Zuletzt bearbeitet von dastef am Mo 30.10.2006 16:26, insgesamt 1-mal bearbeitet
|
|