Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Open pop mailbox
- if (!$mbox = imap_open ("{localhost:110/pop3/notls}INBOX", "user", "tester")) {
- die ('Cannot connect/check pop mail! Exiting');
- }
- if ($hdr = imap_check($mbox)) {
- $msgCount = $hdr->Nmsgs;
- } else {
- echo "Failed to get mail";
- exit;
- }
- $MN=$msgCount;
- $overview=imap_fetch_overview($mbox,"1:$MN",0);
- for ($X = 1; $X <= $MN; $X++) {
- $file = imap_fetchbody($mbox, $X, 1);
- imap_delete($mbox, $X);
- }
- imap_expunge($mbox);
- imap_close($mbox);
- msgsubmit: "| /usr/bin/php ~path/to/example.php", msgsubmit-box
- msgsubmit
- "| /usr/bin/php ~path/to/example.php"
- msgsubmit-box
- <?php
- //make sure that submit button name is 'Submit'
- if(isset($_POST['Submit'])){
- $name = $_POST['visitorname'];
- $email = $_POST['visitoremail'];
- $message = $_POST['visitormessage'];
- $to="[email protected]";
- $subject="From ".$name;
- $from = $email;
- // generate a random string to be used as the boundary marker
- $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
- // now we'll build the message headers
- $headers = "From: $fromrn" .
- "MIME-Version: 1.0rn" .
- "Content-Type: multipart/mixed;rn" .
- " boundary="{$mime_boundary}"";
- // next, we'll build the invisible portion of the message body
- // note that we insert two dashes in front of the MIME boundary
- // when we use it
- $message = "This is a multi-part message in MIME format.nn" .
- "--{$mime_boundary}n" .
- "Content-Type: text/plain; charset="iso-8859-1"n" .
- "Content-Transfer-Encoding: 7bitnn" .
- $message . "nn";
- foreach($_FILES as $userfile)
- {
- // store the file information to variables for easier access
- $tmp_name = $userfile['tmp_name'];
- $type = $userfile['type'];
- $name = $userfile['name'];
- $size = $userfile['size'];
- // if the upload succeded, the file will exist
- if (file_exists($tmp_name))
- {
- // check to make sure that it is an uploaded file and not a system file
- if(is_uploaded_file($tmp_name))
- {
- // open the file for a binary read
- $file = fopen($tmp_name,'rb');
- // read the file content into a variable
- $data = fread($file,filesize($tmp_name));
- // close the file
- fclose($file);
- // now we encode it and split it into acceptable length lines
- $data = chunk_split(base64_encode($data));
- }
- // now we'll insert a boundary to indicate we're starting the attachment
- // we have to specify the content type, file name, and disposition as
- // an attachment, then add the file content.
- // NOTE: we don't set another boundary to indicate that the end of the
- // file has been reached here. we only want one boundary between each file
- // we'll add the final one after the loop finishes.
- $message .= "--{$mime_boundary}n" .
- "Content-Type: {$type};n" .
- " name="{$name}"n" .
- "Content-Disposition: attachment;n" .
- " filename="{$fileatt_name}"n" .
- "Content-Transfer-Encoding: base64nn" .
- $data . "nn";
- }
- }
- $ok = @mail($to, $subject, $message , $headers);
- if ($ok) {
- if (($_FILES["file"]["type"] == "image/gif")
- || ($_FILES["file"]["type"] == "image/jpeg")
- || ($_FILES["file"]["type"] == "image/pjpeg")
- && ($_FILES["file"]["size"] < 20000))
- {
- if ($_FILES["file"]["error"] > 0)
- {
- echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
- }
- else
- {
- if (file_exists("upload/" . $_FILES["file"]["name"]))
- {
- echo $_FILES["file"]["name"] . " already exists. ";
- }
- else
- {
- move_uploaded_file($_FILES["file"]["tmp_name"],
- "upload/" . $_FILES["file"]["name"]);
- }
- }
- }
- else
- {
- }
- echo "<span class='red'>E-mail has been sent successfully from $mail_name to $to</span>"; }
- else{
- echo "<span class='red'>Failed to send the E-mail from $from to $to</span>";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment