我正在尝试在PHP邮件功能中发送图像附件,但在我的电子邮件中,我只收到文件名,而不是图像。
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['element_2_2'])) {
?>
<?php
$admin_email = "manager.jjm@gmail.com";
$subject = "Quote Received From Copycat";
//Get the uploaded file information
$name_of_uploaded_file = basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file = substr($name_of_uploaded_file,
strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<div style=".'width:100%;float:left;'.">
<div style=".'width: 25%;float:right; text-align: center;'.">
</div>
<div style=".'width:250px;float:left;'.">
<p style=".'color:red;font-size:22px;'.">Your Information</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Firstname: ".$_REQUEST['element_2_1']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Lastname: ".$_REQUEST['element_2_2']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Company Name: ".$_REQUEST['element_2_3']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Address: ".$_REQUEST['element_2_4']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Street Address: ".$_REQUEST['element_2_5']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Address line2: ".$_REQUEST['element_2_56']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">City: ".$_REQUEST['element_2_54']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">State / Province / Region: ".$_REQUEST['element_2_53']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Postal / Zip Code: ".$_REQUEST['element_3_6']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Email: ".$_REQUEST['element_2_512']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Phone: ".$_REQUEST['element_2_5122']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Fax: ".$_REQUEST['element_2_5212']."</p>
</div>
<div style=".'width:250px;float:left;margin-left:20px;'.">
<p style=".'color:red;font-size:22px;'.">Boat Information</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Boat Type: ".$_REQUEST['element_7']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Boat Make: ".$_REQUEST['element_8']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Boat Year: ".$_REQUEST['element_9']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Boat Length: ".$_REQUEST['element_2_10']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Boat Model: ".$_REQUEST['element_2_11']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Current Upholstery Condition: ".$_REQUEST['element_12']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Upholstery Design Ideas: ".$_REQUEST['element_13']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">How Many Parts Need Repaired? </p>
<p style=".'color:#000;font-size:20px;width:100%;color:red'.">Customer wants the ".$_REQUEST['element_13']." parts to repaired,And information is below:</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -1</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width']."X".$_REQUEST['length']."X".$_REQUEST['height']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered'].",Zippers:".$_REQUEST['zip'].",Velcro:".$_REQUEST['vel'].",Image:".$_REQUEST['photo']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -2</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width1']."X".$_REQUEST['length1']."X".$_REQUEST['height1'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered1'].",Zippers:".$_REQUEST['zip1'].",Velcro:".$_REQUEST['vel1'].",Image:".$_REQUEST['photow']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -3</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width2']."X".$_REQUEST['length2']."X".$_REQUEST['height2'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered2'].",Zippers:".$_REQUEST['zip2'].",Velcro:".$_REQUEST['vel2'].",Image:".$_REQUEST['photo3']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -4</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width3']."X".$_REQUEST['length3']."X".$_REQUEST['height3'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered3'].",Zippers:".$_REQUEST['zip3'].",Velcro:".$_REQUEST['vel3'].",Image:".$_REQUEST['photo4']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -5</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width4']."X".$_REQUEST['length4']."X".$_REQUEST['height4'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered4'].",Zippers:".$_REQUEST['zip4'].",Velcro:".$_REQUEST['vel4'].",Image:".$_REQUEST['photo5']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -6</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width5']."X".$_REQUEST['length5']."X".$_REQUEST['height5'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered5'].",Zippers:".$_REQUEST['zip5'].",Velcro:".$_REQUEST['vel5'].",Image:".$_REQUEST['photo6']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -7</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width6']."X".$_REQUEST['length6']."X".$_REQUEST['height6'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered6'].",Zippers:".$_REQUEST['zip6'].",Velcro:".$_REQUEST['vel6'].",Image:".$_REQUEST['photo7']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -8</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width7']."X".$_REQUEST['length7']."X".$_REQUEST['height7'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered7'].",Zippers:".$_REQUEST['zip7'].",Velcro:".$_REQUEST['vel7'].",Image:".$_REQUEST['photo8']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -9</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width8']."X".$_REQUEST['length8']."X".$_REQUEST['height8'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered8'].",Zippers:".$_REQUEST['zip8'].",Velcro:".$_REQUEST['vel8'].",Image:".$_REQUEST['photo9']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -10</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width9']."X".$_REQUEST['length9']."X".$_REQUEST['height9'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered9'].",Zippers:".$_REQUEST['zip9'].",Velcro:".$_REQUEST['vel9'].",Image:".$_REQUEST['photo10']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -11</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width10']."X".$_REQUEST['length10']."X".$_REQUEST['height10'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered10'].",Zippers:".$_REQUEST['zip10'].",Velcro:".$_REQUEST['vel10'].",Image:".$_REQUEST['photo11']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -12</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width11']."X".$_REQUEST['length11']."X".$_REQUEST['height11'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered11'].",Zippers:".$_REQUEST['zip11'].",Velcro:".$_REQUEST['vel11'].",Image:".$_REQUEST['photo12']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -13</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width12']."X".$_REQUEST['length12']."X".$_REQUEST['height12'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered12'].",Zippers:".$_REQUEST['zip12'].",Velcro:".$_REQUEST['vel12'].",Image:".$_REQUEST['photo13']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -14</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width13']."X".$_REQUEST['length13']."X".$_REQUEST['height13'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered13'].",Zippers:".$_REQUEST['zip13'].",Velcro:".$_REQUEST['vel13'].",Image:".$_REQUEST['photo14']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -15</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width14']."X".$_REQUEST['length14']."X".$_REQUEST['height14'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered14'].",Zippers:".$_REQUEST['zip14'].",Velcro:".$_REQUEST['vel14'].",Image:".$_REQUEST['photo15']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -16</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width15']."X".$_REQUEST['length15']."X".$_REQUEST['height15'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered15'].",Zippers:".$_REQUEST['zip15'].",Velcro:".$_REQUEST['vel15'].",Image:".$_REQUEST['photo16']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -17</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width16']."X".$_REQUEST['length16']."X".$_REQUEST['height16'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered16'].",Zippers:".$_REQUEST['zip16'].",Velcro:".$_REQUEST['vel16'].",Image:".$_REQUEST['photo17']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -18</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width17']."X".$_REQUEST['length17']."X".$_REQUEST['height17'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered17'].",Zippers:".$_REQUEST['zip17'].",Velcro:".$_REQUEST['vel17'].",Image:".$_REQUEST['photo18']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -19</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width18']."X".$_REQUEST['length18']."X".$_REQUEST['height18'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered18'].",Zippers:".$_REQUEST['zip18'].",Velcro:".$_REQUEST['vel18'].",Image:".$_REQUEST['photo19']."</p>
<p style=".'color:#000;font-size:15px;width:100%;color:red'.">Measurements -20</p>
<p style=".'color:#000;font-size:16px;width:100%'.">".$_REQUEST['width20']."X".$_REQUEST['length20']."X".$_REQUEST['height20'].",</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Covered:".$_REQUEST['covered20'].",Zippers:".$_REQUEST['zip20'].",Velcro:".$_REQUEST['vel20'].",Image:".$_REQUEST['photo20']."</p>
</div>
<div style=".'width:250px;float:left;margin-left:20px;'.">
<p style=".'color:red;font-size:22px;'.">Design Information</p>
<p style=".'color:#000;font-size:16px;width:100%'.">Complete Upholstery Set Repair? ".$_REQUEST['element_95']."</p>
<p style=".'color:#000;font-size:16px;width:100%'.">How Many Parts Need Repaired? ".$_REQUEST['element_951']."</p>
</div>
</div>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
mail($admin_email,$subject,$message,$headers);
}
else{
}
$name=$_REQUEST['element_2_1'];
$user = $_REQUEST['element_2_512'];
$usersubject = "Thank You";
$userheaders = "From: Justina Rudez <teamrudez@gmail.com>\n";
$usermessage = "
Dear $name ,
we received your information we will be back with you shortly. ... ";
mail($user,$usersubject,$usermessage,$userheaders);
?>
我正在尝试超过1个附件。它基于用户选择。现在我正在使用简单的邮件功能,而不是phpmailer。
答案 0 :(得分:0)
不可能,你有两种可能性:
1:upload and save that file to your webserver.
OR
2: create base64/png of that uploaded file
然后使用如下图像
1. <img src="http:/yourdomain.de/thatimage.png">
OR
2. <img src="data:image/png;base64,YW4gaW1n(base64-encoeded image)...">