
 "You Got Email", a PHP-FormToEmail: Script to send an Email From Data submitted on Form with an Attachments To see how to user this script, Please find how to use title in this file.


Copyright (c) 2003 Chirag Ahmedabadi<chirag_kansara@yahoo.com>							

http://www.indianic.com, http://www.php-india.net                    					

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

This script uses the PHP email class by   Brent R. Matzelle as given belwo				
phpmailer - PHP email class
Version 1.65, Created 08/09/2002
Class for sending email using either
sendmail, PHP mail(), or SMTP.  Methods are
based upon the standard AspEmail(tm) classes.
Author: Brent R. Matzelle <bmatzelle@yahoo.com>
License: LGPL, see LICENSE
                                                                      				
This program is free software. You can redistribute it and/or modify 				
it under the terms of the GNU General Public License as published by 				
the Free Software Foundation; either version 2 of the License.       				
phpmailer - PHP email class
Version 1.65, Created 08/09/2002
Class for sending email using either
sendmail, PHP mail(), or SMTP.  Methods are
based upon the standard AspEmail(tm) classes.
Author: Brent R. Matzelle <bmatzelle@yahoo.com>
License: LGPL, see LICENSE


FEATURES

"You Got Email" can process any kind of web forms on your website, like, Contact Us page, support page, Completion Page, Script /resume upload etc. Singe script, no need to install anything. Very simple to use, for standard option, simply no configuration require, just put your email address and you are done. No need to change your existing form or you don't need to do anything specific on your html page to use this script. Lot more; here is the list of features.

Very simple to use only single file and works for all kind of forms

Supports SMTP, Sendmail 

Simply no configuration requires, just put your email address and you are done. 

Works with any form, contact us, competitions, support form, resumes, etc.

Also works for all your current form, no need to change your existing pages.

No need to define particular filed name or name for file input, you can have any thing.

Supports all input on form including multiple select box, file upload, etc

Single scripts works for any number of forms

Unlimited attachments support

User can upload any files from form and are sent to you as an attachment in email

Allows upload/attachment for any kind of file

Optionally, you can save the uploaded files on your server 

You can validate type of files to be sent

You can validate Max size of files to be uploaded

In case of image uploads, you can also validate height and width of the image

Unlimited emails send including cc and bcc

Gets you User/Client data like IP, Agents

Gets you server environment data 

Gets you cookie information on user's pc

You can ignore the data, which is not required

Html emails or text emails as you like

Option to set where you wish to redirect your user after successful email send or on failure to send an email

Allows you to check/test your configuration 


How to use this script?

Very simple to do, follow following step

1. Design your html form by any html editor, if you already have your form ready, fine. 

2. Put proper <form> tag in your html file, if you are going to allow upload of image or photo then don't forget to put it like enctype="multipart/form-data

3. Give action of your script to this file like, if you are going to keep this file in same folder, otherwise change path accordingly

4. It should be something like  " <form action="YouGotEmail.php" method="post" enctype="multipart/form-data">"

5. Open the YouGotEmail.php file in your editor, edit variable called "$SendAddress", put the value of your email address, i.e. email address to which you wish to receive an email. 

If you just wish to have basic option, with this much configuration, the script will send all your data submitted by user on your form, including image upload if you have any, it will also validate that user has uploaded only image files (jpeg, gif) and also will validate size (10240000 bytes) , height (1400) and width (1400) of the image.


CHECKING YOUR CONFIGURATION
If you wish to find out, whether you have configure this properly or not, just call the script directly in browser like http:yoursitename/YouGotEmail.php
This will show you the configuration and if you have some problem, it would show you message in red color. So if you find any text with red color, it means there is some problem.




If you don't wish to have some more features, you are done here. No need to read further. 


MORE FEAUTRES
Here are the other options that you can set

$mail_subject
this will set the subject of email that you or other user receives

$MyContents
if you wish to add your own contents like site name etc, add in this variable

$IgnoreFields 
if you wish to ignore some fields in your email, normally if you will be having submit button on your filed, if you don't ignore it, you will get name of your submit filed with value in your email, to ignore such, put the name of filed here in this list, you can add as many as, by comma separated. For example, in email you get, if you see that some variables are not useful to you, just copy the name of that variable and put it here in list, it would not add in next email

$PutPostData
Normally you will set this to 1, this will put all the post data in your email, i.e. what user has submitted on your form.

$PutGetData
if you have get method on your form action set this to 1

$PutEnvData
set this to 1, if you wish to receive environment data in your email like HOSTNAME, MACHTYPE etc

$PutServerData
Set this to 1, if you wish to have Server Data in your email like REMOTE_ADDR, HTTP_USER_AGENT, REMOTE_PORT etc

$PutCookieData
Set this to 1, if you wish to receive cookie information of client machine.

$PutAllData
Set this to 1, if you wish to receive all above data, don't prefer this, you may receive confusing and weird email.

$isThereAttachment
Set this to 1, if you have any file upload option on your form

$TempFolder 
Give absolute path here of folder where you wish to save your upload files for temporary if you have set not save file by setting variable, $DeleteUploadFiles to 0, all the files will be deleted after sending email to you.

$my_max_file_size
This sets the max size of the file that you wish to receive in your email, files larger than this will be deleted and will not be sent to you in email.

$allowed_types
This sets what kind of files you wish to receive in your email like image, word etc. For example if you are going to allow upload Ms Office file, you can add like application/msword,application/x-excel etc. The file other than this will be deleted and will not be sent in email.

$image_max_width
if you have set allowed types to images, like gif, jpeg etc. This will validate width of image and image with higher width other then this will be deleted and will not be sent in email.

$image_max_height
if you have set allowed types to images, like gif, jpeg etc. This will validate height of image and image with higher height other then this will be deleted and will not be sent in email.

$DeleteUploadFiles
Set this to 1, if you wish to save the files uploaded by user, if you have not set path, for temp folder then it will save the files in same folder where the script is located. If you set this to 0, it will delete all the files after sending an email to you.

$SendCCTo[]
This is an array, if you wish to send CC to some user(s), then add comma-separated list here.

$SendBCCTo []
This is an array, if you wish to send BCC to some user(s), then add comma-separated list here.

$EmailFromAddress
this sets the from address, which you will see in your email box when you receive an email. If not set, it will display your email address that you set very first in variable $SendAddress.

$EmailFromName
Somewhat user-friendly name in from address. If not set, it will display your email address that you set very first in variable $SendAddress.

$ReplyToAddress
Sets the reply address, that is the address which you see when you click reply to received email. . If not set, it will display your email address that you set very first in variable $SendAddress.

$ReplyToName
Sets user friendly, reply address, that is the address which you see when you click reply to received email. If not set, it will display your email address that you set very first in variable $SendAddress.

$isHTMLMail
set this to 0, if you don't wish to receive email with HTML format.

$SendUserToSucess
Set the URL where you wish to redirect your user after successfully email sent to you. Like thanks page etc. If not set, then it would send user back to page from where he has arrived, to your form.

$SendUserToFail
Set the URL where you wish to redirect your user in case email cannot be sent successfully. If not set, then it would send user back to page from where he has arrived, to your form.

$TableStart
This is a html code to format table start for your email

$DataLoop
this is html code by which all the variables and its value are put/formatted for email.

$TableEnd
This is a html code to format table end for your email



TESTED 
Tested on Linux with Global Register Off/On and sendmail. If you wish to use with SMTP, please find out the details about the SMTP in script file.


CONCEPT
This script finds out the posted/get data on your form and puts in variable name and value pair in your email. Files uploaded are sent as an attachment in email. 


LIMITATION
The main limitation of the script is the variable name that you get in the email. Like if you have input box on your form with name="yourname", you will get same name in your email. It does not allow you to change text of this. However, this compromise is done to make the script use simple and with minimum configuration.


SUGESSTION
If you are designing new form try to use form description field name, like "Your Name". So your email will be more readable.


BUGS
Trying to find out, if you find any email me webmaster@php-india.net or visit http://www.php-india.net forum on this script.

Thanks

Chirag


