这恰好是我在这里的第一篇文章,而且我无论如何都不是程序员,但由于这样的论坛,我确实设法找到了解决代码的方法。下面是我从某个地方挑选出来的代码,我已经以发布到我的电子邮件的形式实现了它。我现在的问题是,当我在邮件中收到填写表格的副本时,整个信息都打包成一行,我尝试使用 \n 作为换行符,但都无济于事。
然而,这不是整个代码,但我确实觉得问题出在这些代码的某个地方。
这就是我得到的;
First Name: 3 Last Name: s Date of Birth: 1/1/1111 Gender: Female Address Line1: a Address Line2: a etc ...
当我真正想要的结果是这样的时候;
First Name: 3
Last Name: s
Date of Birth: 1/1/1111
Gender: Female
Address Line1: a
Address Line2: a
etc ....
下面是截断的代码。
$message="First Name: ".$firstname."
Last Name: ".$lastname."
Date of Birth: ".$dateofbirth."
Gender: ".$gender."
Address Line1: ".$address1."
Address Line2: ".$address2."
City: ".$city."
State: ".$state."
Country: ".$country."
Zip Code: ".$zipcode."
Phone Number: ".$phone."
Email: ".$email."
Fax: ".$fax."
Type of Identification: ".$identification."
Expiry Date: ".$expiry."
Identification Number: ".$idnumber."
Occupation: ".$occupation."
Annual Salary: ".$salary."
Position: ".$position."
Office Address: ".$oaddress."
Office Phone: ".$ophone."
Employer's Name: ".$ename."
Account Type: ".$accountype."
";
$message = stripslashes($message);
$from = "$email";
if (!empty($_FILES['picture']['tmp_name'])) {
// Get attachment
$imagename = $_FILES['picture']['name'];
$source = $_FILES['picture']['tmp_name'];
$target = "../account/ids/".$imagename;
move_uploaded_file($source, $target);
$suffix =strtolower(substr($target, -3));
switch($suffix) {
case 'gif': $typ = "image/gif"; break;
case 'jpg': $typ = "image/jpg"; break;
case 'peg': $typ = "image/jpeg";break;
case 'png': $typ = "image/png"; break;
case 'pdf': $typ = "application/pdf"; break;
case 'zip': $typ = "application/zip"; break;
}
$subject = "Online Account Application Form";
$fileatt = $target;
$fileatttype = $typ;
$fileattname = $imagename;
$headers = "From: $from";
$file = fopen( $fileatt, 'rb' );
$data = fread( $file, filesize( $fileatt ) );
fclose( $file );
$semi_rand = md5( time() );
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"utf-8\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$template_top.$message.$template_bottom . "\n\n";
$data = chunk_split( base64_encode( $data ) );
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileattname}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileattname}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
在此先感谢您的帮助。