# Need my PHP form to send $user email with attachment

**URL:** <https://forum.kirupa.com/t/need-my-php-form-to-send-user-email-with-attachment/318575>\
**Category:** programming\
**Created:** [January 24, 2011, 3:15pm UTC](https://forum.kirupa.com/t/need-my-php-form-to-send-user-email-with-attachment/318575 "2011-01-24T15:15:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![spindrift](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@spindrift](https://forum.kirupa.com/u/spindrift)\
**Post date:** [January 24, 2011, 3:15pm UTC](https://forum.kirupa.com/t/need-my-php-form-to-send-user-email-with-attachment/318575/1 "2011-01-24T15:15:54Z")

</div>

Hi guys,

I have a PHP form which submits the result to me and also sends the $user a ‘thank you’ email, which works fine.

What I want to do is for the email that the $user is sent to have an attachment (probably PDF).

Does anyone know if this is possible and if so, how I could edit my code?

My code looks like:

```auto

<?php

$to = "me@mydomain.com";
$subject = "Form Submission";

$email=$_POST['email'] . "
";

$message = $headers;
$message .= "Name: " . $_POST["firstname"] . "
";
$message .= "Surname: " . $_POST["surname"] . "
";
$message .= "Company: " . $_POST["company"] . "
";
$message .= "Address: " . $_POST["address1"] . ", " . $_POST["address2"] . ", " . $_POST["address3"] . ", " . $_POST["postcode"] . "
";
$message .= "E-mail: " . $_POST["email"] . "
";
$message .= "E-mail Confirm: " . $_POST["email_confirm"] . "
";
$message .= "Telephone: " . $_POST["tel"] . "
";
$message .= "Spend: " . $_POST["aams"] . "
";

$message .= "Mailing List: " . $_REQUEST['mailinglist'] . "
";

$url = stripslashes($_POST["url"]);
if (!empty($url)) {
header( 'Location: http://www.google.com' );
exit();
}

mail($to, $subject, $message, $headers);

header( 'Location: http://www.mydomain.co.uk/sent.php' ) ;

$user = "$email";
$usersubject = "Thank you for registering";
$userheaders = "From: me@mydomain.com
";

$usermessage = "Dear " . $_POST["firstname"] . ",

Thank you for filling out my online form. Please see the attached document.

From me
www.mydomain.com
";

mail($user,$usersubject,$usermessage,$userheaders); 

?>

```

Many thanks and I hope to hear from you.

SM
