Php表单到电子邮件附件

Php表单到电子邮件附件,php,forms,email,attachment,Php,Forms,Email,Attachment,文件附件不适用于上述代码。有什么解决办法吗?附加文件的代码中有什么错误?我需要附加所有类型的extn文件 <?php $c_name=$_POST['c_name']; $title=$_POST['title']; $comp_name=$_POST['comp_name']; $add_1=$_POST['add_1']; $add_2=$_POST['add_2']; $city=$_POST['city']; $state_name=$_POST['state_name']; $

文件附件不适用于上述代码。有什么解决办法吗?附加文件的代码中有什么错误?我需要附加所有类型的extn文件

<?php

$c_name=$_POST['c_name'];
$title=$_POST['title'];
$comp_name=$_POST['comp_name'];
$add_1=$_POST['add_1'];
$add_2=$_POST['add_2'];
$city=$_POST['city'];
$state_name=$_POST['state_name'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$message=$_POST['message'];
$hear=$_POST['hear'];
$upload_file=$_POST['upload_file'];



    $body .= "Contact Name: " . $c_name . "\n"; 
    $body .= "Title: " . $title . "\n"; 
    $body .= "Company Name: " . $comp_name . "\n"; 
    $body .= "Address 1: " . $add_1 . "\n";
    $body .= "Address 2: " . $add_2 . "\n";
    $body .= "City: " . $city . "\n";
    $body .= "State/Province: " . $state_name . "\n";
    $body .= "Zip Code: " . $zip . "\n";
    $body .= "Phone: " . $phone . "\n";
    $body .= "Fax: " . $fax . "\n";
    $body .= "E-mail: " . $email . "\n";
    $body .= "Message: " . $message . "\n";
    $body .= "Hear about us from:" . $hear . "\n"; 
    $file .= "". $upload_file . "\n";


    //replace with your email
    mail("example@example.com","New email",$body,$file); 


?>

您可以从中获取PHPMailer类,并根据需要使用:)

<?php

$c_name=$_POST['c_name'];
$title=$_POST['title'];
$comp_name=$_POST['comp_name'];
$add_1=$_POST['add_1'];
$add_2=$_POST['add_2'];
$city=$_POST['city'];
$state_name=$_POST['state_name'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$message=$_POST['message'];
$hear=$_POST['hear'];
$upload_file=$_POST['upload_file'];



    $body .= "Contact Name: " . $c_name . "\n"; 
    $body .= "Title: " . $title . "\n"; 
    $body .= "Company Name: " . $comp_name . "\n"; 
    $body .= "Address 1: " . $add_1 . "\n";
    $body .= "Address 2: " . $add_2 . "\n";
    $body .= "City: " . $city . "\n";
    $body .= "State/Province: " . $state_name . "\n";
    $body .= "Zip Code: " . $zip . "\n";
    $body .= "Phone: " . $phone . "\n";
    $body .= "Fax: " . $fax . "\n";
    $body .= "E-mail: " . $email . "\n";
    $body .= "Message: " . $message . "\n";
    $body .= "Hear about us from:" . $hear . "\n"; 
    $file .= "". $upload_file . "\n";


    //replace with your email
    mail("example@example.com","New email",$body,$file); 


?>