TGWSE_GY Posted August 30, 2010 Share Posted August 30, 2010 OK so I am trying to send a email with the results of a submitted form to a specified email address. However when the email is received the data is not displayed rather the variable names are. See code and resulting email address below. // custom route code //Send Email // recipients $to = '********@*********.com'; // subject $subject = 'Jobs Form Submission!'; // message $message = ' <html> <head> <title>Jobs Form Submission!</title> </head> <body> Title: $job_title<br /> Company: $job_company<br /> Introduction: $job_intro <br /> Description: $job_description <br /> Required Qualifications: $job_req_qualifi <br /> Preferred Qualifications: $job_preerred_qualifi <br /> Contact Name: $job_contact_name <br /> Contact Company: $job_contact_company <br /> Contact E-mail: $job_contact_email <br /> Contact Phone: $job_contact_phone <br /> Contact Fax: $job_contact_fax <br /> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: ******** <********@*********.com>' . "\r\n"; $headers .= 'From: $job_contact_email <$job_contact_email>' . "\r\n"; $headers .= 'Cc:' . "\r\n"; $headers .= 'Bcc:' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); Email Address: MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 To: ********<******@**********.com> From: $job_contact_email <$job_contact_email@***********.com> Cc: <html> <head> <title>Jobs Form Submission!</title> </head> <body> Title: $job_title<br /> Company: $job_company<br /> Introduction: $job_intro <br /> Description: $job_description <br /> Required Qualifications: $job_req_qualifi <br /> Preferred Qualifications: $job_preerred_qualifi <br /> Contact Name: $job_contact_name <br /> Contact Company: $job_contact_company <br /> Contact E-mail: $job_contact_email <br /> Contact Phone: $job_contact_phone <br /> Contact Fax: $job_contact_fax <br /> </body> </html> Any pointers would be great. Thanks in advance 0_o Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 30, 2010 Share Posted August 30, 2010 Anything inside of a single-quoted string is interpreted as a literal value. You'd need to use double quotes around the strings, or proper string concatenation to get it to work as intended. Quote Link to comment Share on other sites More sharing options...
TGWSE_GY Posted August 30, 2010 Author Share Posted August 30, 2010 Thanks Pikachu2000 that worked in getting the contents of the variables into the email itself but the HTML tags are still showing up rather than formatting the email. Any ideas of why that would be happening? Thanks again! Quote Link to comment Share on other sites More sharing options...
TGWSE_GY Posted August 31, 2010 Author Share Posted August 31, 2010 Ok so I found the solution or at least the solution that worked for me other than I receive 2 emails from one submission of the form. However the header issue was in fact because I was trying to send html and some applications remove the custom headers by default ie. MS Outlook, and many others. So I corrected this issue by removing all html code from the message and used \n for a carriage return. Below is the code I am using now. Once I find a fix for the duplicate emails I will post that solution as well. Thanks again for your time and help. // recipients $to = "******@********.com"; // subject $subject = "Jobs Form Submission!"; // message $message =" Title: " . $job_title . "\n Company: " . $job_company . "\n Introduction: " . $job_intro . "\n Description: " . $job_description . "\n Required Qualifications: " . $job_req_qualifi . "\n Preferred Qualifications: " . $job_preerred_qualifi . "\n Contact Name: " . $job_contact_name . "\n Contact Company: " . $job_contact_company . "\n Contact E-mail: " . $job_contact_email . "\n Contact Phone: " . $job_contact_phone . "\n Contact Fax: " . $job_contact_fax . "\n "; // To send HTML mail, the Content-type header must be set $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; // Additional headers $headers .= "From: " . $job_contact_email ."\r\n"; $headers .= "Reply-To: " . $job_contact_email . " \r\n"; // Mail it mail($to, $subject, $message, $headers); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.