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

}

}

?>

Link to comment
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');             

              }

            }

            ?>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.