PRodgers4284 Posted March 12, 2008 Share Posted March 12, 2008 I am looking to send an file attachment by email, i am using a wamp and i have configured the settings to send mail, and this works fine for sending ordinary text emails. My code for sending mail is: [code]require_once('class.phpgmailer.php'); $mail = new PHPGMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = 'ssl://smtp.gmail.com'; // SMTP servers $mail->FromName = '"""""".com'; $mail->AddAddress($email); $mail->Subject = 'Jobs4U Registration'; $mail->Body = "Your account has been successfully created with the following details:\n\nUsername: $username\nPassword: $password\nEmail: $email\nForename: $forename\nSurname: $surname\nLocation: $location\n\nPlease click on the link to activate your account.\n http://localhost/Jobs4U/activate.php?username=$username"; $mail->Send(); [/code] I have a file upload working which stores a file to a directory and the path to the file is stored in the database: My code for file upload is: $uploadDir = 'applicationforms/'; if (isset($_POST['submit']) && $error_stat == 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; // move the files to the specified directory // if the upload directory is not writable or // something else went wrong $result will be false $result = move_uploaded_file($tmpName, $filePath); include("database.php"); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } How can i send the file attachment to a email instead of uploading to the database, any help or advice would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/95784-php-mail-attachment/ Share on other sites More sharing options...
skidz Posted March 12, 2008 Share Posted March 12, 2008 i use phpmailer class for this.... it's extremely simple if you wanted to try it out! Link to comment https://forums.phpfreaks.com/topic/95784-php-mail-attachment/#findComment-490348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.