簡體   English   中英

php發送一封帶有附件的郵件,然后將其復制出去

[英]php send one mail with attachment and copy with out

我今天做了我的mailer php的第一個應用程序,非常好,發送了2個pdf附件,

但是為了保持記錄,我需要一份郵件副本才能轉到另一封郵件,但沒有附件,

如何做到這一點?

此處的代碼(編輯,抱歉,)

表格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     = "xxx@ax.com.au";
$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:x@x.com.au">x@nx.com.au</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/>


    '
    ?>

非常感謝!

要使用PHP發送簡單郵件,您需要:

  • 收件人電子郵件ID
  • 學科
  • 信息
  • 標頭

要附加文件,您必須使用multipart Content-Type

因此,您可以編寫一個自定義函數,該函數接受所需的變量,然后發送兩封郵件-一封要發送帶有附件的郵件,另一封要發送到另一個不帶附件的電子郵件ID進行記錄保存。

我在phpFreaks的幫助下做到了

很簡單! 謝謝怪胎!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM