Jump to content

PHP Mail attachment


PRodgers4284

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.