Richiesta Informazioni
http://www.phphq.net :- Copyright(c) 2005 All Rights Reserved :- :- This script 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, or :- (at your option) any later version. :- :- This script is distributed in the hope that it will be useful, :- but WITHOUT ANY WARRANTY; without even the implied warranty of :- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the :- GNU General Public License for more details. :-http://www.gnu.org/licenses/gpl.txt :- //================================================================================ * Description //================================================================================ :- phMailer is a very simple php mail script. It can be used on your site as a contact form. This is very helpful if you want your visitors to be :- able to contact you without them knowing your real email address. On great feature of this script is the ability to allow users :- to attach multiple files when sending an email directly from your site. Of course, you can disable this feature if you wish. :- Any file type is accepted as long as they are included in your file extension list. Another popular use for a php email form is :- protection against spam bots. Spam, is a major downside of email, and placing your email publicly on your website is asking :- for spam. Spam bots can take your email address right off your site and add it to thousands of spam databases, resulting in a :- never ending supply of spam for you. I coded this script, because I couldn't find a simple mail script that would allow my visitors :- to send me attachments while keeping my email hidden from spam bots. Enjoy another easy but advanced script from phphq.Net Customs! //================================================================================ * Setup //================================================================================ :- To setup this script, simply drop this file anywhere in your website. Then edit the variables in phMailer.php (Variables can be found below this readme). //================================================================================ * Frequently Asked Questions //================================================================================ :- Q1: I never receive any mail, but people say they have emailed me through the form. :- A1: Try the mailtest.php file that came with this script. If that fails, then mail() is not setup right. Please contact your host :- A2: Did you change anything within the file? Are you sure your email is correct? :- A3: Try using the form with $allowattach set to 0. It could be your mail server rejecting the mail because of attachments. :- A4: If you are on windows, make sure your SMTP is set to your mail server. If you are on Linux, make sure your sendmail path if correct. Again, ask your host. :- :- Q2: I never receive any attachments. :- A1: Maybe your server has some security against uploading files or sending attachments through mail, check with your host on this issue. This script does send attachments, it's been tested many times on many different platforms and versions of php with safe mode on and off. :- A2: Maybe the files people are submitting are too big. Check php.ini for the post_max_size, upload_max_filesize, file_uploads, max_execution_time you may have to check with your host on this. :- :- Q3: The page takes forever to load and then times out bringing me to a page cannot be displayed! Stupid script! :- A1: This is usually due to a low value in php.ini for max_execution_time. Ask your host to increase the value. Be aware that the time needed depends on the size the file(s) users are sending and the speed of THERE internet connection for uploading the files. If they are on 56k uploading 1mb will take forever, so the value may need to be set very high! :- A2: You really can have as many attachments as you want. I tested up to 10 attachments on Windows 2003 Server / XP & Red Hat 9/ Enterprise Linux 3/4. Several reasons could cause this. Your mail server could be rejecting that many at one time, your post_max_size, upload_max_filesize, file_uploads, max_execution_time in php.ini might be set to low or off. Contact your host to resolve this. :- :- Q4: How do I edit the colors of the form? :- A1: Due to many requests I used CSS instead of hard coding it into the php. I also made it easier to understand. The only bad part is if you are extremely novice you may have problems editing the CSS. Check http://www.w3schools.com/css/default.asp to brush up on CSS to change the colors of this script. The CSS is located near the end of this script. :- :- Q5: Can I add more fields for the users to enter information in? :- A1: That's the beauty of php! It's open source, you can edit it all you want, change whatever you don't like etc. Just please leave in my copyright. So many times I see my script without it and it makes me sad. :- :- Q6: Dude! Can you add more fields for me? I don't know php! :- A1: Maybe, but I do usually charge a fee depending on what you want done. Don't freak out! It's usually a very small one. If I'm having a very good day and feel rich (ha-ha) I might do it for free.. :- :- Q7: Can I remove your copyright? :- A1: I can't really physically stop you. But it's much appreciated by the people that leave it on there. Some people donate me $15-$20 to take it off. If you donate a small amount to me I might just not care as much. :- A2: When I go to your site and see this script no matter how much you tried to edit it to hide the fact, I usually know it's mine and will usually report it to your host if I'm not to busy. ~35 down and counting! :- A3: So basically unless I say it's ok just leave it on there.. It doesn't hurt you at all does it? Does that little bit of text just make your balls itch? If it's that bad then go ahead... :- :- Q8: You never respond to my emails or in your forums (http://www.phphq.net/forums/)! :- A1: I know and I'm sorry. I'm a very busy guy. I'm out of town a lot, and at any given time I have several projects going on. I get a lot of emails about this script, not to mention my other ones. Sometimes I just get too many of the same emails.. I usually clear out my inbox every week on a non specific day. :- A2: I only understand English. If you do know English but it's very bad please write in your native language and then translate it to English using http://babelfish.altavista.com/babelfish/tr :- A3: You will get a much faster and much more detailed response if you write a decent message. "dude me form don't work see it at blah.com what's wrong??!?!" will get no response, ever. Write in detail what the problem is and what you did to try and fix it. Spend a minute on it, and I'll take some of my time to reply. :- A4: Please don't speak in h4x0r language. I do understand it but it's very annoying to me. I will most likely just chuckle and delete it. :- */ /* //================================================================================ * ! ATTENTION ! //================================================================================ :- Please read the above FAQ before giving up or emailing me. It may sort out your problems! */ // This will show in the
"; } If(trim($youremail)=="") { $error.="You did not enter your email!
"; } Elseif(!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)) { $error.="Invalid email address.
"; } If(trim($emailsubject)=="") { $emailsubject=$defaultsubject; } If(trim($yourmessage)=="") { $error.="You did not enter a message!
"; } // Verify Attchment info If($allowattach > 0) { //Loopish For($i=0; $i <= $allowattach-1; $i++) { If($_FILES['attachment']['name'][$i]) { $ext=get_ext($_FILES['attachment']['name'][$i]); $size=$_FILES['attachment']['size'][$i]; $max_bytes=$max_file_size*1024; //Check if the file type uploaded is a valid file type. If(!in_array($ext, $allowtypes)) { $error.= "Invalid extension for your file: ".$_FILES['attachment']['name'][$i].", only ".$types." are allowed.
"; //Check the size of each file } Elseif($size > $max_bytes) { $error.= "Your file: ".$_FILES['attachment']['name'][$i]." is to big. Max file size is ".$max_file_size."kb.
"; } } // If Files } // For //Tally the size of all the files uploaded, check if it's over the ammount. $total_size=array_sum($_FILES['attachment']['size']); $max_file_total_bytes=$max_file_total*1024; If($total_size > $max_file_total_bytes) { $error.="The max size allowed for all your files is ".$max_file_total."kb
"; } } // If Allowattach If($error) { $display_message=$error; } Else { If($use_subject_drop AND is_array($subjects) AND is_array($emails)) { $subject_count=count($subjects); $email_count=count($emails); If($subject_count==$email_count) { $myemail=$emails[$emailsubject]; $emailsubject=$subjects[$emailsubject]; } } $boundary=md5(uniqid(time())); //Little bit of security from people forging headers. People are mean sometimes :( $yourname=clean($yourname); $yourmessage=clean($yourmessage); $youremail=clean($youremail); //Headers $headers="From: ".$yourname." <".$youremail.">\n"; $headers.="Reply-To: ".$yourname." <".$youremail.">\n"; $headers.="MIME-Version: 1.0\n"; $headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n"; $headers.="X-Mailer: PHP/".phpversion()."\n"; $headers.="X-Priority: ".$priority."\n"; $headers.="Return-Path: <".$youremail.">\n"; $headers.="This is a multi-part message in MIME format.\n"; //Message $message = "--".$boundary."\n"; $message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $message.="Content-Transfer-Encoding: quoted-printable\n"; $message.="\n"; $message.="$yourmessage"; $message.="\n"; //Lets attach to something! =) If($allowattach > 0) { For($i=0; $i <= $allowattach-1; $i++) { If($_FILES['attachment']['name'][$i]) { $message.=phattach($_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]); } } //For } // If // End the message $message.="--".$boundary."--\n"; // Send the completed message If(!mail($myemail,$emailsubject,$message,$headers)) { Exit("An error has occured, please report this to the website administrator.\n"); } Else { $sent_mail=true; } } // Else } // $_POST /* //================================================================================ * Start the form layout //================================================================================ :- Please know what your doing before editing below. Sorry for the stop and start php.. people requested that I use only html for the form.. */ ?>
}?> } Else {?>
}?> //Please leave this here.. it really dosen't make people hate you or make your site look bad.. ?>