2011-01-20 280 views
0

我沒有我的郵件PHP的首次應用的今天,很漂亮,送2個PDF附件,PHP發送一個郵件帶附件和複印出來

但對記錄保存,我需要的郵件副本去另一封郵件,但沒有附件,

如何完成此操作?

這裏的代碼(編輯,對不起,)

HTML表單:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html> 
<head> 
<title>Contact Form</title> 
<meta name="Generator" content="Alleycode HTML Editor"> 
<meta name="Description" content="Your description here..."> 
<meta name="Keywords" content="Your keywords here..."> 
</head> 
<body> 
<form method="post" action="sendmail2.php"> 
<p> 
<label>Name:</label> <br/> <input type="text" name="name" size="48" height="40"/> 
</p> 
<p> 
<label>Email:</label> <br/> <input type="text" name="email" size="48" height="40"/> 
</p> 
<p> 
<label>Child's Name:</label> <br/> <input type="text" name="childname" size="48" height="40"/> 
</p> 
<p> 
<label>Site:</label> 
<br/> 
<textarea name="site" rows="2" cols="45" overflow:hidden>xx.com.au</textarea> 
</p> 
<p>&nbsp;</p> 
<p> 
<label>Days:</label> 
<br/> 
<textarea name="days" rows="2" cols="45" overflow:hidden>Monday, Tuesday, Wednesday, Thursday, Friday</textarea> 
</p> 
<p>&nbsp;</p> 
<p> 
<input type="submit" value="Send"/> 
<a href="xx/form.html">clear</a></p> 
</form> 
</body> 
</html> 

sendmail2.php:

<?php 
require("../phpmailer/class.phpmailer.php"); 
include("email.php"); 
$name = $_POST['name']; 
$childname = $_POST['childname']; 
$site = $_POST['site']; 
$days = $_POST['days']; 
$mail = new PHPMailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth = true; 
$mail->Host = "xxx.com"; // SMTP servers 
$mail->Username = "xxx"; // SMTP username 
$mail->Password = "xxx"; // SMTP password 
$mail->AddAddress($_POST['email']); 
$mail->From  = "[email protected]"; 
$mail->FromName = "xxx_online"; 
$mail->Subject = "Message from Alouette"; 
$mail->IsHTML(true); 
$mail->Body = $message; 
$mail->AddAttachment("../attachs/x.pdf"); 
$mail->AddAttachment("../attachs/xd.pdf"); 
if($mail->Send()) { 
echo "Message sent! Thanks !   "; 
print('<a href="xu/mail/form.html">Reset and Back</a>'); 
} 
?> 

email.php

<?php 
$message = ' 
Hello '.$name.', <br/> 
we have received your interest in child care services for '.$childname.' from the '.$site.' website. <br/> 
<br/> 
'.$days.' 
<br/> <br/> 
Should you have any questions regarding the information on our enrolment form or services please do not hesitate to contactkkk 
<br/> <br/> <br/> 

Regards, <br/> 


<a href="mailto:[email protected]">[email protected]</a> &nbsp;&nbsp;&nbsp; <a href="http://www.nx.com.au" target="_new">www.neo-it.com.au</a> 
<br/> 
<strong>Childcare Management Services</strong> 
<br/> <br/> 


    ' 
    ?> 

非常感謝很多!

+0

請顯示您現在使用的代碼。 – 2011-01-20 11:07:36

+4

只需創建沒有附件的相同郵件併發送它? – 2011-01-20 11:09:41

回答

0

我就是這麼做的與phpFreaks

很簡單的幫助 ! 謝謝怪胎!

0

對於PHP發送一個簡單的郵件,您需要:

  • 接收電子郵件ID
  • 主題
  • 消息

對於附加文件,你要使用multipart內容類型

因此,您可以編寫一個自定義函數,它接受所需的變量,併發送兩封郵件 - 一個用於發送帶有附加文件的郵件,另一個用於另一個沒有記錄附件附件的電子郵件ID。