如何在PHP中添加在线邮件附加文件的功能?

时间:2013-12-11 20:51:26

标签: php email

我现在一直在寻找这个问题很长一段时间,但在我的具体问题上找不到确切的答案。

它是这样的:我如何添加将文件附加到我用PHP编写的在线电子邮件的可能性? :)

以下是代码:

<?php 
session_start();

if( isset($_POST['submit'])) 
{
     if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) 
       {  
       $to=$_POST["to"];
       $from=$_POST["from"];
       $name=$_POST["name"];
       $subject=$_POST["subject"];
       $message=$_POST["message"];
       $message=$message."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
       $head="From: ".$from."\r\n".'Reply-To: '.$From."\r\n";
       $her=$head.' < '.$from.' >';
       $techomag=mail($to, $subject, $message, $her);
       echo "Your Message Has been send successfully...:)..";
           unset($_SESSION['security_code']);
      echo( '<a href="mysite.com/index.php">Click here to send another email</a>' );
      } 
      else 
      {

        echo 'Sorry, you have provided an invalid captcha security code :(...';
        echo( '<a href="mysite.com/index.php">Click here to Go back and try once more</a>' );
      }

} 
else 
{
?>
<?php
?>


<div style="height:10px; clear:both"></div>

<form action="index.php" method="post">
   <table border="1"><tbody>
   <tr><td>To Email :</td><td><input name="to" type="text" /></td></tr>
   <tr><td>From Email :</td><td><input name="from" type="text" /></td></tr>
   <tr><td>From Name :</td><td><input name="name" type="text" /></td></tr>
   <tr><td>Subject :</td><td><input name="subject" type="text" /></td></tr>
   <tr><td>Message :</td><td><textarea cols="30" rows="10" name="message"></textarea></td></tr>
   <tr><td><img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /><br />
   <label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text" />
   <input type="submit" name="submit" value="Send Email!" /></td></tr>
   </tbody></table>
</form>

<?php

}

?>

谢谢你:)

0 个答案:

没有答案