WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Email attachment code
Categories : PHP, Email, Filesystem Update Picture
dheeraj dhawan
Date : May 02nd 2009
Grade : 5 of 5 (graded 3 times)
Viewed : 6961
File : 4962.php
Images : No Images for this code example.
Search : More code by dheeraj dhawan
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
// Path to the file
$fileatt = "";

// File Type
$fileatt_type = "application/octet-stream";

// Filename that will be used for the file as the attachment
$fileatt_name = "";

// Who the email is from
$email_from = "";

// The Subject of the email
$email_subject = "";

// Message that the email has in it
$email_txt = "";

// Who the email is too
$email_to = "";

$headers = "From: ".$email_from;

// check if your file is exist in your folder or not
if (file_exists($fileatt)) {
    echo
"The file $fileatt exists";
}else{
    echo
"The file $fileatt does not exist";
}


$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);


$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";

$email_message .=    "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" .
                   
"Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";

$data = chunk_split(base64_encode($data));

$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";

$ok = @mail($email_to, $email_subject, $email_message, $headers);

if(
$ok) {
    echo
"<font face=verdana size=2>The file was successfully sent!</font>";
}else{
    die(
"Sorry but the email could not be sent. Please go back and try again!");
}
?>



PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
Massreplace
Categories : Filesystem, Regexps, Strings, PHP
Solution to those 'tell-a-friend' type email issues
Categories : PHP, Email, Databases, MySQL
A simple php file uploader
Categories : PHP, Filesystem, HTML and PHP
Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms
Open directory and File download
Categories : PHP, Filesystem, Directories, HTML and PHP
3 lines of Code to extract Tar, Zip, Gzip etc..
Categories : PHP, Filesystem, PHP Classes, Compression
GuestBook Light - a plug and play application for any website.
Categories : PHP, Complete Programs, Filesystem, Sessions
QTO File Manager
Categories : Filesystem, filePro, Complete Programs, PHP, Content Management
how can I read the entire contents of a file into a string?
Categories : Filesystem, Strings, PHP
Clever Email Validation Function - E-Mail validation function with an eregi expression and socket connection.
Categories : Email, PHP, Regexps
Relative Path
Categories : PHP, Filesystem
PHP3 FormMail This script sends E-mail using PHP3 function mail(). Body of message is from text file that you create. Easily modified.
Categories : PHP, Email, IMAP
Customer feedback or simple emailer - A PHP script that enables your visitors to send you emails.
Categories : PHP, Email, Form Processing
Directory Viewer, Directory Content Viewer, Directory Structure to HTML. This code will basically create a complete set of HTMLs to let a user navigate through any directory you want. Excellent code for large file sharing pages.
Categories : Directories, Filesystem, PHP