これはたまたまここでの最初の投稿であり、さらに私はプログラマーではありませんが、このようなフォーラムのおかげでコードを回避する方法を見つけることができます. 以下は、どこかから抜粋したコードで、メールに投稿するフォームに実装しました。私の問題は、記入済みのフォームのコピーをメールで受け取ると、情報全体が 1 行に詰め込まれていることです。改行に \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";
よろしくお願いします。