Jump to content

PHP mail attachment


bruckerrlb

Recommended Posts

Hello,

 

I have a simple php mail form, which sends when the person fills out the form, but I need for them to be able to upload an attachment and that attachment gets sent to the person as well as the form info. The following code I have

 

<?php
$description = $_POST['description'];
$requirements = $_POST['requirements'];
$location = $_POST['location'];
$salary = $_POST['salary'];
$priority = $_POST['priority'];
$agreement = $_POST['agreement'];
$screen1 = $_POST['screen1'];
$screen2 = $_POST['screen2'];
$screen3 = $_POST['screen3'];
$screen4 = $_POST['screen4'];



//Save visitor name and entered message into one variable:
$formcontent="Description: $description \n\n Requirements: $requirements \n\n Location: $location \n\n Salary: $salary \n\n Priority: $priority \n\n Agreement in Place: $agreement \n\n Screening question 1: $screen1 \n\n Screening question 2: $screen2 \n\n Screening question 3: $screen3 \n\n Screening question 4: $screen4";
$recipient = "[email protected]";
$subject = "Partner Submit";
$mailheader = "From: him\r\n";
$mailheader .= "Reply-To: noreply\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure");
?>

 

So I have a couple questions maybe you guys can help me out with, where would I put the attachment, as well as is there anyway I get get the attachment to send without it being stored on our server? How should I go about doing this? I have tried to have an upload form, and tried to attach that uploaded file to get sent, but it breaks the entire file.

 

Any help much appreciated!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/105792-php-mail-attachment/
Share on other sites

Thanks, I checked out the link and tried to get it working, but it's really complicated, and I"m not sure if I need to build my own form to use that, and if so, will I be declaring the variables it uses in that file. It comes with three files, but no instructions and the demo's it provides are for something a bit different than I'm trying to do, which is just simply a user uploads a file and it gets sent with the rest of the form information.

 

I appreciate the link, if you have any more, or any other suggestions on how I can do this, I would really appreciate it.

Link to comment
https://forums.phpfreaks.com/topic/105792-php-mail-attachment/#findComment-542246
Share on other sites

Maybe someone can help me with this, or at least point me in the right direction. I am a semi-mature, and struggle with all things that have to do with php and mail. Could someone tell me what needs to be done? I understand if this is too much to ask, but I am just really curious about this because I haven't struggled with something like this, this long.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/105792-php-mail-attachment/#findComment-543069
Share on other sites

Thanks, I checked out the link and tried to get it working, but it's really complicated, and I"m not sure if I need to build my own form to use that, and if so, will I be declaring the variables it uses in that file. It comes with three files, but no instructions and the demo's it provides are for something a bit different than I'm trying to do, which is just simply a user uploads a file and it gets sent with the rest of the form information.

 

I appreciate the link, if you have any more, or any other suggestions on how I can do this, I would really appreciate it.

 

the first example file, example.1.php, is very simple and inludes:

/**

* Example of usage. This example shows

* how to use the class with html,

* embedded images, and an attachment.

 

the examples are very well commented, so if you don't want html or embedded images, you can see where to remove those pieces, leaving the attachment.

 

 

Link to comment
https://forums.phpfreaks.com/topic/105792-php-mail-attachment/#findComment-543147
Share on other sites

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.