FranktheTank Posted March 30, 2011 Share Posted March 30, 2011 Hi, I am new to php and I desperately need help inserting an image into my php submit form. The form works perfectly but I have no idea how to get an image to be shown when the recipeint fo the email receive it (would love to have my company logo at the top of the mail just after $message.. Below is my code : .... // Create Mail Message and Send Mail $to = 'x@domain.coma'; $subject = "Website Enquiry Received from www.domain.com"; $message = "The following message has been sent from the website." . "\n" . "\n" . "Date Sent: " . date("j F Y") . "\n" . "Date Sent: " . date("g:i a") . "\n" . "\n" . "From: $contactName $contactSurname" . "\n" . "\n" . "Their Contact & Personal Details" . "\n" . "=====================" . "\n" . "\n" . "Marital Status: $contactStatus" . "\n" . "Email: $contactEmail" . "\n" . "Cellphone Number: $contactNumber" . "\n" . "Address 1: $contactAddress1" . "\n" . "Address 2: $contactAddress2" . "\n" . "Suburb: $contactSuburb" . "\n" . "Postal Code: $contactPostalcode" . "\n" . "\n" . "\n" . $headers = "From: $contactName $contactSurname <$contactEmail>" . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); mail($contactEmail, 'Confirmation of email: "' . $subject . '"', $message, $headers); // Thank You Message header('Refresh: 0; url=/quote_confirm.htm'); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232146-insert-image-in-a-php-email-submit-form/ Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 The only way this works is if you are sending an html format email. You simply inlcude an img tag just as you would for any other html page. Quote Link to comment https://forums.phpfreaks.com/topic/232146-insert-image-in-a-php-email-submit-form/#findComment-1194167 Share on other sites More sharing options...
FranktheTank Posted March 30, 2011 Author Share Posted March 30, 2011 Thanks Gizmola ! So do I just add that tag like this ? $message = "The following message has been sent from the website." . <img src="http://www.yoursite.com/path/to/img/yourimg.jpg> "\n" . "\n" . "Date Sent: " . date("j F Y") . "\n" . "Date Sent: " . date("g:i a") . "\n" . "\n" . "From: $contactName $contactSurname" . "\n" . "\n" . "Their Contact & Personal Details" . "\n" . "=====================" . "\n" . "\n" . "Marital Status: $contactStatus" . "\n" . "Email: $contactEmail" . "\n" . "Cellphone Number: $contactNumber" . "\n" . "Address 1: $contactAddress1" . "\n" . "Address 2: $contactAddress2" . "\n" . "Suburb: $contactSuburb" . "\n" . "Postal Code: $contactPostalcode" . "\n" . "\n" . "\n" . $headers = "From: $contactName $contactSurname <$contactEmail>" . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); mail($contactEmail, 'Confirmation of email: "' . $subject . '"', $message, $headers); // Thank You Message header('Refresh: 0; url=/quote_confirm.htm'); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232146-insert-image-in-a-php-email-submit-form/#findComment-1194170 Share on other sites More sharing options...
gizmola Posted March 30, 2011 Share Posted March 30, 2011 Yes. Most clients these days will autodetect that you have html in the content body and display it as html. Just as a little tip, you really don't need to have all those concatenation operators in there on every line. What you have in your reply isn't valid for example, as you have a long string that you never terminate. At any rate, this is a lot easier to read and maintain: $mybigstring = "This starts here\n And another line\n And another one\n etc."; Quote Link to comment https://forums.phpfreaks.com/topic/232146-insert-image-in-a-php-email-submit-form/#findComment-1194182 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.