mediengestalter.info
FAQ :: Mitgliederliste :: MGi Team

Willkommen auf dem Portal für Mediengestalter

Aktuelles Datum und Uhrzeit: Sa 20.04.2024 02:19 Benutzername: Passwort: Auto-Login

Thema: Mail-Versand / Attachment Enconding, base64 vom 30.10.2006

Neues Thema eröffnen   Neue Antwort erstellen MGi Foren-Übersicht -> Programmierung -> Mail-Versand / Attachment Enconding, base64
Autor Nachricht
ron.deida
Threadersteller

Dabei seit: 06.03.2006
Ort: Regensburg
Alter: 43
Geschlecht: Männlich
Verfasst Mo 30.10.2006 14:00
Titel

Mail-Versand / Attachment Enconding, base64

Antworten mit Zitat Zum Seitenanfang

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
  View user's profile Private Nachricht senden Website dieses Benutzers besuchen
Ähnliche Themen PHP MIME MAIL Attachment und Umlaute fürn Mac
HTML-Mail-Versand via PHP
formular-versand ohne mail-prog
[Google Mail] Lesebestätigung + verzögerter Versand
SVG: Font einbetten (Base64-codiert)
GMX Attachment - Bild läd nicht
Neues Thema eröffnen   Neue Antwort erstellen
MGi Foren-Übersicht -> Programmierung


Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst an Umfragen in diesem Forum nicht mitmachen.