Làm cách nào để thêm CC và BCC trong PHPMailer?

Tôi không thể hiểu dòng này. Ghi chú. chức năng này hoạt động với trình gửi thư SMTP trên win32, không hoạt động với trình gửi thư "mail"

<html>
<head>
<title>PHPMailer - SMTP basic test with authentication</title>
</head>
<body>

<?php
include("config.php");
//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();


//$body             = file_get_contents('contents.php');
//$body             = eregi_replace("[\]",'',$body);



$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >30 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows30p = mysql_num_rows($result);  //30+

$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) <=30 AND TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >=22 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows2230 = mysql_num_rows($result); // 22-30

$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) <=21 AND TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >=15 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows1521 = mysql_num_rows($result); // 15-21

$query  = "SELECT `SiteId`,`OwnerName`,MONTHNAME(`DurationS`),`pDate` FROM lims_payment WHERE TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) <=14 AND TO_DAYS( NOW( ) ) - TO_DAYS(  `pDate` ) >=1 AND  `cDate` LIKE  '0000-00-00' AND  `crDate` LIKE  '0000-00-00' AND  `rDate` LIKE  '0000-00-00'
AND rfDate LIKE  '0000-00-00'";
$result = @MYSQL_QUERY($query);
$num_rows115 = mysql_num_rows($result); // 1-15



 $body			= "<html><body style='margin: 10px;'>
<div style='width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;'>
Dear Payable/Finance <br />
Please find the attached sheet of pending payments at your end (starting from 15-21). Following is the summary of attached sheet.  <br />
<table  border='1' bordercolordark='#000000' cellpadding='10'>
  	<tr>
    <td width='42%' style='background: #eee;'><strong>Total Days</strong></td>
    <td width='58%' style='background: #eee;'><strong>No. of Payments</strong></td>
	</tr>
	
	 	 	<tr>
    <td width='42%'>0-14</td>
    <td width='58%'>$num_rows115</td>
	</tr>
		
		<tr>
    <td width='42%'>15-21</td>
    <td width='58%'>$num_rows1521</td>
	</tr>
	
		 	<tr>
    <td width='42%'>22-30</td>
    <td width='58%'>$num_rows2230</td>
	</tr>
	
		 	<tr>
    <td width='42%'>30+</td>
    <td width='58%'>$num_rows30p</td>
	</tr>

</table>
<br />
Engineering Database:<br />
Generated Automatically by Engineering Database<br />
Please, DO NOT Reply to this System Generated Email.<br /></div></body></html>"; 



$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "*******"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "********"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "*****"; // SMTP account username
$mail->Password   = "*****";        // SMTP account password

$mail->SetFrom('edb@****.com.pk', 'Engineering Databse');

$mail->AddReplyTo("*****@****.com.pk","First Last");

$mail->Subject    = "Engineering Database Report";

//$mail->AddEmbeddedImage('phpmailer.gif', 'phpmailer', 'phpmailer.gif '); use this in $body for viewing <img src='cid:phpmailer' alt='phpmailer' />

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);


$mail->AddAddress("****@****.com.pk", "Furqan");

$mail->AddCC('****@****.com.pk', 'First Person'); // this not working


$mail->AddAttachment("Excel/LongOutstandings.xlsx");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

</body>
</html>

php

0 0

Chia sẻ

Đã chỉnh sửa 11 năm trước bởi Ezzaral vì. Đã thay đổi thẻ TEX khó đọc thành trích dẫn

  • 4 Người đóng góp
  • 8 Trả lời
  • 2K Lượt xem
  • 1 năm Khoảng thời gian thảo luận
  • Bài đăng mới nhất Bài đăng mới nhất bởi keshav539

Câu trả lời được đề xuất

Đã trả lời bởi urtrivedi 276 trong một

Đối với cc của riêng bạn, bạn có thể thử

$mail->addCustomHeader("Cc. {$yourccmailid1},{$yourccmailid2}");

Đã trả lời bởi urtrivedi 276 trong một

Tôi đang đăng mã đơn giản nhất ở đây để gửi thư. Nó không yêu cầu sử dụng bất kỳ lớp nào

<?php

	$headers= "MIME-Version: 1.0\n";
	$headers.="Content-type: text/html; charset=iso-8859-1\n";
	$headers.="Cc: [email protected],[email protected]\n";	
	$headers.="Bcc: [email protected],[email protected]\n";	
	$subject = "sample mail";
	$message="<br><b>this is just a sample</b>.";
	
	$message.="<br><br>This is system generated message. Please do not reply.";						
         $sendmail …

Tất cả 8 câu trả lời

Làm cách nào để thêm CC và BCC trong PHPMailer?

urtrivedi 276 Gần như một bậc thầy về đăng bài

11 năm trước

Đối với cc của riêng bạn, bạn có thể thử

$mail->addCustomHeader("Cc. {$yourccmailid1},{$yourccmailid2}");

0 0

Chia sẻ

Làm cách nào để thêm CC và BCC trong PHPMailer?

ayesha789 7 Đăng bài chuyên nghiệp trong đào tạo

11 năm trước

Đối với cc của riêng bạn, bạn có thể thử

$mail->addCustomHeader("Cc. {$yourccmailid1},{$yourccmailid2}");

Bằng cách sử dụng dòng trên, nó hiển thị bằng cc khi "để" nhận email, nhưng "cc"
email không nhận được email, nó chỉ hiển thị trong cc

0 0

Chia sẻ

Làm cách nào để thêm CC và BCC trong PHPMailer?

ayesha789 7 Đăng bài chuyên nghiệp trong đào tạo

11 năm trước

Email hoạt động tốt, tôi cũng có thể thêm Cc bằng Tiêu đề tùy chỉnh, nhưng Email không gửi đến Địa chỉ Cc

Ngoài ra, tôi muốn biết rằng tôi đang sử dụng Windows 2003 Server và XAMPP với PHP Mailer và SMTP Authentication. Tại sao nó báo lỗi

this function works with the SMTP mailer on win32, not with the "mail" mailer.

0 0

Chia sẻ

Làm cách nào để thêm CC và BCC trong PHPMailer?

ayesha789 7 Đăng bài chuyên nghiệp trong đào tạo

11 năm trước

Bất cứ ai cũng có thể có bất kỳ ý tưởng nào về nó, tôi đang sử dụng win32 nhưng mặc dù nó không hoạt động

0 0

Chia sẻ

Làm cách nào để thêm CC và BCC trong PHPMailer?

ayesha789 7 Đăng bài chuyên nghiệp trong đào tạo

11 năm trước

Tôi ở đây với hy vọng ai đó có thể cho tôi bất kỳ manh mối nào về vấn đề của mình

0 0

Chia sẻ

Làm cách nào để thêm CC và BCC trong PHPMailer?

urtrivedi 276 Gần như một bậc thầy về đăng bài

11 năm trước

Tôi đang đăng mã đơn giản nhất ở đây để gửi thư. Nó không yêu cầu sử dụng bất kỳ lớp nào

<?php

	$headers= "MIME-Version: 1.0\n";
	$headers.="Content-type: text/html; charset=iso-8859-1\n";
	$headers.="Cc: [email protected],[email protected]\n";	
	$headers.="Bcc: [email protected],[email protected]\n";	
	$subject = "sample mail";
	$message="<br><b>this is just a sample</b>.";
	
	$message.="<br><br>This is system generated message. Please do not reply.";						
         $sendmail = mail("[email protected]", $subject, "<html><body>".$message."</body></html>", $headers);
		

?>

0 0

Chia sẻ

Làm cách nào để thêm CC và BCC trong PHPMailer?

garyf123 0 Áp phích dành cho người mới

11 năm trước

Tôi đã sử dụng AddCC của PHPMailer trong một thời gian dài mà không gặp sự cố trên máy chủ linux/cpanel. Gần đây tôi đã thay đổi sang máy chủ linux/plesk và hiện tôi gặp sự cố này

Làm cách nào để đặt CC trong PHPMailer?

$mail ->AddCC( "địa chỉ phụ3@tên miền. com" ); //và gửi. Bây giờ điều đó không dễ dàng sao? .

Làm cách nào để thêm nhiều cc vào thư PHP?

Mặc dù tham số $to chỉ chấp nhận một chuỗi, nhưng bạn có thể chuyển một giá trị địa chỉ email được phân tách bằng dấu phẩy như minh họa bên dưới. // 👇 chỉ định nhiều người nhận $to = "john@mail. com, jane@mail. com" $subject = "Xin chào thế giới. "; $message = "Thời tiết hôm nay thật tuyệt. "; // 👇 gửi thư mail($to, $subject, $message);

Làm cách nào để gửi nhiều email trong PHPMailer?

phpmailer. php'); . com'; . $ email->send()) { echo "Lỗi Mailer. "

PHPMailer có sử dụng SMTP không?