Embed image in php mailer

Hi i have tried several suggestions of adding an image to the email sent out in my form but none works.

Here is the form code.

<?php session_start(); include('inc/config.php'); include('inc/functions.php'); include('inc/header.php'); ?> .responsive { width: 100%; max-width: 300px; height: auto; }

Tell A Friend About Printer Mania.

A pre set message will be sent inviting your friend to visit Printer Mania.

Your Name :



Friend’s Email Address :



<? if (@$_POST['Send']=="Send") { $name=$_POST['name']; $email=$_POST['email']; $subject = $name. " recommends this site !"; $image=$image; $message= "Hello, \n\n" .$name. " thought you might be interested in visiting the following website : \n\nhttps://www.mywebsite \n\n It has a beautiful memorial cushion to remember your loved one. \n\n You can personalise the image, name and dates."; $headers = 'From: my email' . "\r\n" . 'Reply-To: myemail' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email, $subject, $message, $headers, $mail,); echo "Your email was sent to: $email

Thank You for recommending my website"; } ?>
<?php include('inc/footer.php'); ?>

First, please format your code so it is readable. This run-on list of commands is hard to read!

Next, you have $image=$image. What is that, makes no sense at all.
If you are emailing an image and want it inside the email, you either have to place the image into the email as an embedded base64 object, OR, more correctly, have the image on your server and use HTML emails and just place the code in the HTML email where it belongs.
Also, you are suppressing code results instead of handling them. In live websites, you never use @ when you are reading a posted field. You always handle errors before the PHP code ever sees the $_POST array’s data. You check if a field is valid, if so, handle it, if not throw an error message.

Sponsor our Newsletter | Privacy Policy | Terms of Service