Copy link to clipboard
Copied
My php contact form is working properly but whenever my client receives an email from the form, the email looks very disorganized because all of the contact information that the user has submittted, comes in one line.
Here is my php code
$To = "fakemail";
$Subject = "fake message";
$From = "fake user";
$Message = "Name: " . $Name. "Email " . $Email. "Phone" . $Phone. "Options" . $Options. "Comments" . $Comments;
$Headers = "From: ". $from . "<" . $to. ">\r\n";
$Headers .= "Reply-To: " . $email_text . "\r\n";
$Headers .= "Return-path: ". $email_text;
$result = mail($To, $Subject, $Message, $Headers);
I would like to add the "\n" after each .$Name, .$Email, etc variable so when my client receives the message it will come out like
Name: Bob
Email: fake@email.com
Phone: 123345
etc....
Thanks in advanced
Copy link to clipboard
Copied
More than line breaks, a table would look best. Here's the code:
$mailBody = '<table border="1">';
$mailBody .= '<tr>';
$mailBody .= '<td>Name :</td><td>'.$fullName.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>Title :</td><td>'.$title.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>Company :</td><td>'.$company.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>City :</td><td>'.$city.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>State :</td><td>'.$state.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>Postal Code :</td><td>'.$postal.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>Country :</td><td>'.$country.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>Phone Number :</td><td>'.$phoneNo.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>E-Mail :</td><td>'.$eMail.'</td>';
$mailBody .= '</tr><tr>';
$mailBody .= '<td>Message :</td><td>'.$message.'</td>';
$mailBody .= '</tr>';
$mailBody .= '</table>';
Copy link to clipboard
Copied
Sudarshan Thiagarajan wrote:
More than line breaks, a table would look best. Here's the code:
A table won't work unless the headers also set the Content-type to text/html. By default, the mail() function uses plain text.
Copy link to clipboard
Copied
David, I overlooked OP's headers and failed to mention this in my reply. Sorry about that and thanks for pointing it out! ![]()
Copy link to clipboard
Copied
David, Now I fully understand, Thanks!
Sudarshan, still, I do appreciate your help.
Copy link to clipboard
Copied
Very simple:
$Message = "Name: " . $Name. "\r\n\r\nEmail: " . $Email. "\r\n\r\nPhone: " . $Phone. "\r\n\r\nOptions: " . $Options. "\r\n\r\nComments: " . $Comments;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now