How to send attachment in email?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TanuLamba15
    New Member
    • Feb 2015
    • 3

    #1

    How to send attachment in email?

    Hi All,

    I want attachment to send with the email when a prospect clicks on submit button.

    I used this code:

    Code:
    $allowed = array( 'jpg', 'gif','zip');
    
    if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
    
    	$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
    
    	if(!in_array(strtolower($extension), $allowed)){
    		echo '{"status":"error"}';
    		exit;
    	}
    
    	if(move_uploaded_file($_FILES['upl']['tmp_name'], 'uploads/'.$_FILES['upl']['name'])){
    		echo '{"status":"success"}';
    		exit;
    	}
    }
    
    echo '{"status":"error"}';
    exit;
    but I could not receive any attachment in my mail, I'm new to PHP so Can anyone help me for this how can I get attachement in my mail.

    Thanks in advance!
    Last edited by Rabbit; Mar 11 '15, 03:42 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you don’t send emails with that code, that’s upload only.

    anyways, I recommend to use a mailing library as setting up everything manually is a tedious and error prone job.

    Comment

    Working...