www.webdeveloper.com
Results 1 to 3 of 3

Thread: Sending attachement to email

  1. #1
    Join Date
    Feb 2009
    Posts
    47

    Sending attachement to email

    Hi,

    I'm making a fileupload function that will create a watermark and border on the image uploaded.
    And then it is supposed to send an email with the image to an email that is typed in a field.
    But it comes with an error, it works individually, but when I put the mail function and the watermark thing together it doesn't work.

    This is the error:

    Parse error: syntax error, unexpected '}' in /home/www/wearecrunch.dk/watermark/somefile.php on line 52

    And this is my code:

    PHP Code:


    <?php
        
    include_once( 'class/class.upload.php' );
        if(isset(
    $_POST['upload'])){
            
    $handle = new upload($_FILES['file_name']);
            
    $handle->allowed = array('image/*');
            if(
    $handle->uploaded){
                
    $handle->image_border          5;   // defining border width
                
    $handle->image_border_color    '#F58462'// defining border color
                
    $handle->image_watermark 'site-logo.png';  // watermark image src
                
    $handle->image_watermark_position 'BR'// watermark image position again "B" for bottom and so on.
                
    $handle->image_resize         true;   // making resize function to true
                
    $handle->image_x              160;    // making width to 160px
                
    $handle->image_y              160;    // making hight to 160px
                
    $handle->process('uploads/');
                if (
    $handle->processed) {
                    
    //$message = '<div class="center"><p>Border color #F58462 added successfully</p><img src="uploads/'.$handle->file_dst_name.'" alt="" /></div>';
                    
                     //*** Uniqid Session ***//
        
    $strSid md5(uniqid(time()));
        
    $to $_POST['mail'];
        
    $from 'my@gmail.com'
        
    $subject 'the subject';
        
    $headers 'From: '.$from"\r\n" 'Reply-To: '.$from"\r\n";
        
    $headers .= "MIME-Version: 1.0\n";
        
    $headers .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
        
    $headers .= "This is a multi-part message in MIME format.\n";
        
    $headers .= "--".$strSid."\n";
        
    $headers .= "Content-type: text/html; charset=utf-8\n";
        
    $headers .= "Content-Transfer-Encoding: 7bit\n\n";
        if(
    $_FILES["file_name"]["name"] != "") {
        
    $strFilesName $_FILES["file_name"]["name"];
        
    $strContent chunk_split(base64_encode(file_get_contents($_FILES["file_name"]["tmp_name"])));
        
    $headers .= "--".$strSid."\n";
        
    $headers .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
        
    $headers .= "Content-Transfer-Encoding: base64\n";
        
    $headers .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
        
    $headers .= $strContent."\n\n";
        }
        
    $flgSend = @mail($to$subject$message$headers); // @ = No Show Error //
        
    if($flgSend)
                    
                    
    //echo $message;
                
    }
            }
        }
    ?>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,178
    You forgot the opening "{" a couple lines above.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Sep 2012
    Posts
    2
    Hi,
    Email attachments allow you to send files along with your email messages. An attachment can be any type of file, but the most common ones are text documents and images (photos etc).

    Before you send an attachment, you need to know where it is located on your computer. Usually you will have saved the file using Windows Explorer or some other software. Whenever you save a file to use as an attachment, select "Save As..." and make a note of where you save it. If you can't find a file, use the Windows search function.

    Once you know where the file is you can create the email message.

    Create a new email message and enter the usual details (recipient address, subject, etc).
    Look for an icon in your toolbar which looks like a paper clip and click it.
    A "Browse" window will open. Locate and select the attachment file.
    before you send an attachment, you must be sure the person receiving it will be able to open it. Not all attachments will work on someone else's computer!

    In order to open your attachment the recipient must have the appropriate software. Some types of files are very common and most people can open them, but other types can be rare or require expensive software.

    These files are quite common and safe:

    .txt - Plain text file
    .jpg (or .jpeg) - Image file for photos etc
    .gif - graphic file

    These files are often used for attachments, but they also cause a lot of problems:

    .doc - MS Office document
    .xls - MS Excel Spreadsheet
    .pub - MS Publisher document
    regards.
    bizworldusa

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles