Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP: Variableninhalt als Datei per Email verschicken

Empfohlene Antworten

Veröffentlicht

Hi,

ich generiere den Inhalt einer FDF-Datei (für pdf-Import) und möchte diesen dann als FDF-Datei versenden.

Das verschicken der Datei klappt auch, allerdings kommt der Inhalt nicht wie gewünscht an.

Muss ich extra dafür eine Tempdatei anlegen oder kann ich den Variableninhalt direkt als Dateiinhalt in den Header schreiben (wie ich es momentan versuche)?


$file_content = $fdfdata;
$file_content = chunk_split(base64_encode($file_content));

$boundary = strtoupper(md5(uniqid(time())));

// Header -> E-Mail-Infos
$mail_header = "From:$vorname $nachname <$email>\n";
$mail_header .= "MIME-Version: 1.0";
$mail_header .= "\nContent-Type: multipart/mixed; boundary=$boundary";
$mail_header .= "\n\nThis is a multi-part message in MIME format";
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: text/plain";
$mail_header .= "\nContent-Transfer-Encoding: 8bit";
$mail_header .= "\n\n$nachricht";
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: application/octetstream; name=\"test2.fdf\"";
$mail_header .= "\nContent-Transfer-Encoding: base64";
$mail_header .= "\nContent-Disposition: attachment; filename=\"test2.fdf\"";
$mail_header .= "\n\n$file_content";
$mail_header .= "\n--$boundary--";
[/PHP]

In der ankommenden Datei steht dann nur "Resource id #1" statt des vorher generierten Inhaltes aus $fdfdata".

Was mache ich falsch?

  • Autor

Hab nen Fehler entdeckt.

Bei Dateianhängen darf man keinen Mailbody als Parameter mitschicken, der muss ab in den Header.

  mail("$empfaenger_name <$empfaenger_email>","$subject","", $mail_header);

So ists richtig.

Mit obigem Code kann man dann Variableninhalte als beliebige Datei versenden.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.