Php表单到电子邮件附件

时间:2016-08-17 10:41:43

标签: 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'];
$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); 


?>

1 个答案:

答案 0 :(得分:1)

您可以从PHPMailer Script获取PHPMailer类并使用您想要的:)