PHP-Programmierer chatten hier
Anonymous
Senden einer mehrteiligen E-Mail mit (HTML, Nur-Text und Anhang) in PHP
Post
by Anonymous » 21 Dec 2025, 20:53
Ich sende eine mehrteilige E-Mail mit PHP mit HTML-Formatierung und einem Anhang...
Alles funktioniert gut, aber wenn der Benutzer diese E-Mail von unserer Website erhält, wird die Grenze auch im letzten Teil des HTML-Teils angezeigt.
Aber wenn ich die Grenzlinie entferne, zeigt die E-Mail den Dateiinhalt als Base64 an (kein Anhang).
Code: Select all
if ( isset($_POST['submit']) )
{
$to = '[email protected] ';
$FromSubmitting = $_POST['submitting'];
$FromTitle = $_POST['title'];
$FromName = $_POST['name'];
$FromDesignation = $_POST['designation'];
$FromQualification = $_POST['qualification'];
$FromInstitute = $_POST['institute_address'];
$FromHomeAddress = $_POST['home_address'];
$FromEmail = $_POST['email'];
$FromWorkPhone = $_POST['work_phone_number'];
$FromHomePhone = $_POST['home_phone_number'];
$FromMobilePhone = $_POST['mobile_phone_number'];
$FromPresentingAuthor = $_POST['presenting_author'];
$FromConferenceTheme = $_POST['conference_theme'];
$FromTypeOfSubmission = $_POST['type_of_submission'];
$subject = "New ".$FromSubmitting." Submitted From: ".$FromName;
/* GET File Variables */
$tmpName = $_FILES['uploaded_file']['tmp_name'];
$fileType = $_FILES['uploaded_file']['type'];
$fileName = $_FILES['uploaded_file']['name'];
/* Start of headers */
$headers = "From: $FromEmail";
if (file($tmpName)) {
/* Reading file ('rb' = read binary) */
$file = fopen($tmpName,'rb');
$data = fread($file,filesize($tmpName));
fclose($file); /* a boundary string */
$randomVal = md5(time());
$mimeBoundary = "==Multipart_Boundary_x{$randomVal}x";
/* Header for File Attachment */
$headers .= "\nMIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n" ;
$headers .= " boundary=\"{$mimeBoundary}\"";
/* Multipart Boundary above message */
$message .= "--{$mimeBoundary}\n"
. "Content-Type: text/html; charset=UTF-8\n"
. "Content-Transfer-Encoding: 8bit\n\n"
. "
Submission Type:$FromSubmitting
Name:$FromTitle $FromName
Designation:$FromDesignation
Qualification:$FromQualification
Institute:$FromInstitute
Home Address:$FromHomeAddress
Work Phone:$FromWorkPhone
Home Phone:
$FromHomePhoneMobile Phone:
$FromMobilePhone
Presenting Author:$FromPresentingAuthor
Conference Theme:$FromConferenceTheme
Type of Submission:$FromTypeOfSubmission
"
. "--{$mimeBoundary}\n"; // when removing this line it shows Image-2
/* Encoding file data */
$data = chunk_split(base64_encode($data));
/* Adding attchment-file to message*/
$message .= "--{$mimeBoundary}\n"
. "Content-Type: {$fileType};\n"
. " name=\"{$fileName}\"\n"
. "Content-Transfer-Encoding: base64\n\n"
. $data . "\n\n"
. "--{$mimeBoundary}--\n";
}
$flgchk = mail ("$to", "$subject", "$message", "$headers");
}
E-Mail-Screenshot
Bild-1 :
E-Mail-Screenshot
Bild-2 :
1766346799
Anonymous
Ich sende eine mehrteilige E-Mail mit PHP mit HTML-Formatierung und einem Anhang... Alles funktioniert gut, aber wenn der Benutzer diese E-Mail von unserer Website erhält, wird die Grenze auch im letzten Teil des HTML-Teils angezeigt. Aber wenn ich die Grenzlinie entferne, zeigt die E-Mail den Dateiinhalt als Base64 an (kein Anhang). [code] if ( isset($_POST['submit']) ) { $to = '[email protected] '; $FromSubmitting = $_POST['submitting']; $FromTitle = $_POST['title']; $FromName = $_POST['name']; $FromDesignation = $_POST['designation']; $FromQualification = $_POST['qualification']; $FromInstitute = $_POST['institute_address']; $FromHomeAddress = $_POST['home_address']; $FromEmail = $_POST['email']; $FromWorkPhone = $_POST['work_phone_number']; $FromHomePhone = $_POST['home_phone_number']; $FromMobilePhone = $_POST['mobile_phone_number']; $FromPresentingAuthor = $_POST['presenting_author']; $FromConferenceTheme = $_POST['conference_theme']; $FromTypeOfSubmission = $_POST['type_of_submission']; $subject = "New ".$FromSubmitting." Submitted From: ".$FromName; /* GET File Variables */ $tmpName = $_FILES['uploaded_file']['tmp_name']; $fileType = $_FILES['uploaded_file']['type']; $fileName = $_FILES['uploaded_file']['name']; /* Start of headers */ $headers = "From: $FromEmail"; if (file($tmpName)) { /* Reading file ('rb' = read binary) */ $file = fopen($tmpName,'rb'); $data = fread($file,filesize($tmpName)); fclose($file); /* a boundary string */ $randomVal = md5(time()); $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; /* Header for File Attachment */ $headers .= "\nMIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed;\n" ; $headers .= " boundary=\"{$mimeBoundary}\""; /* Multipart Boundary above message */ $message .= "--{$mimeBoundary}\n" . "Content-Type: text/html; charset=UTF-8\n" . "Content-Transfer-Encoding: 8bit\n\n" . " Submission Type:$FromSubmitting Name:$FromTitle $FromName Designation:$FromDesignation Qualification:$FromQualification Institute:$FromInstitute Home Address:$FromHomeAddress Work Phone:$FromWorkPhone Home Phone: $FromHomePhoneMobile Phone: $FromMobilePhone Presenting Author:$FromPresentingAuthor Conference Theme:$FromConferenceTheme Type of Submission:$FromTypeOfSubmission " . "--{$mimeBoundary}\n"; // when removing this line it shows Image-2 /* Encoding file data */ $data = chunk_split(base64_encode($data)); /* Adding attchment-file to message*/ $message .= "--{$mimeBoundary}\n" . "Content-Type: {$fileType};\n" . " name=\"{$fileName}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mimeBoundary}--\n"; } $flgchk = mail ("$to", "$subject", "$message", "$headers"); } [/code] E-Mail-Screenshot [b]Bild-1[/b]: [img]https://i.sstatic.net/hLPyi.png[/img] E-Mail-Screenshot [b]Bild-2[/b]: [img]https://i.sstatic.net/EARk5.png[/img]
0 Replies
0 Views
Last post by Anonymous
21 Dec 2025, 20:53
0 Replies
26 Views
Last post by Anonymous
03 Oct 2025, 02:31
0 Replies
624 Views
Last post by Anonymous
03 Oct 2025, 04:13
0 Replies
31 Views
Last post by Guest
27 Jan 2025, 04:09
0 Replies
50 Views
Last post by Anonymous
16 Apr 2025, 07:35