Jump to content

Insert Image in a php email / submit form


FranktheTank

Recommended Posts

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      = '[email protected]';

$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');

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/232146-insert-image-in-a-php-email-submit-form/
Share on other sites

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');             

              }

            }

            ?>

 

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.";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.