PHP send email BCC & CC using SMTP

HiDayurie Dave

I have an PHP code to send email to, cc & bcc.

In this case, the cc is not working. I tested it and saw on my email there is no cc email. (BCC email is worked)

Here is my code:

require_once "Mail.php";

$from = "WEBAPPS <[email protected]>";
$subject = "Calibration will be expiring!";

$host = 'smtp.office365.com';
$port = '587';
$username = 'donotreply@test';
$password = 'w00ew?';

$to = "[email protected]";
$cc = "[email protected]";
$bcc = "[email protected]";

$body = "aa";

$headers = array(
'Port'          => $port,
'From'          => $from,
'To'            => $to,
'Subject'       => $subject,
'Content-Type'  => 'text/html; charset=UTF-8'
);

$recipients = $to.", ".$cc.", ".$bcc;

$smtp = Mail::factory('smtp',
array ('host' => $host,
 'auth' => true,
 'username' => $username,
 'password' => $password));

$mail = $smtp->send($recipients, $headers, $body);

if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
} else {
   echo("<p>Message successfully sent!</p>");
}

Why CC is not working? and how to solve it?

AndreaBogazzi

The carbon copy is an header. All recipients are recipients in the same way for the mail server, the difference between carbon copy and blind carbon copy is just a matter of declaring it in the headers.

$headers = array(
'Port'          => $port,
'From'          => $from,
'To'            => $to,
'Subject'       => $subject,
'Content-Type'  => 'text/html; charset=UTF-8',
'Cc'            => $cc
);

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to send cc and bcc recipients in Laravel 7?

分類Dev

Indy SMTP服务器-如何检测CC和BCC收件人?

分類Dev

How do I schedule an email to send at a certain time using cron and smtp, in python?

分類Dev

How to send email in Linux shell script using SMTP without providing the password?

分類Dev

PHPMailer Mass mailing using BCC and catching not successfull email addressses

分類Dev

Sending email using luasocket smtp and ssl

分類Dev

Cannot send email using PHPMailer

分類Dev

send data using ajax and then send email

分類Dev

Can I authenticate SMTP using SwiftMailer without sending an email

分類Dev

Sending email from asp.net using Gmail SMTP OAUTH

分類Dev

Conditional execution of a PHP script to send email

分類Dev

How to configure a server to send email using cPanel?

分類Dev

Using Django to send Email to a User at a scheduled time

分類Dev

How to send email with multiple attachments using this code

分類Dev

Send an HTML email using the Gmail API

分類Dev

PL/SQL - Send cyrillic characters using utl_smtp

分類Dev

How do I tell Prometheus' Alertmanager to send email through Gmail's SMTP server

分類Dev

Outlook VBA Auto BCC - Multiple Email Accounts

分類Dev

Add arguments cc and bcc blackberry.invoke.MessageArguments in javascript

分類Dev

AWS - PHP form to send email - doesn't send email to same domain

分類Dev

Codeigniterの電子メールライブラリ、send()メソッドでのcc、bcc値へのアクセス方法

分類Dev

電子メールの送信時にテストが失敗する:メッセージを送信するにはSMTP宛先アドレスが必要です。メッセージsmtp_envelope_to、to、cc、またはbccアドレスを設定します

分類Dev

メッセージを送信するには、SMTP宛先アドレスが必要です。メッセージsmtp_envelope_to、to、cc、またはbccアドレスを設定します

分類Dev

2019 PHPMailer 6.07 / PHP Scrip How to send an email working example

分類Dev

PHP Mailer shows no errors but doesn't send the email

分類Dev

How to send notification automatically to logged in user secondary email address in php?

分類Dev

PHP Mail()/ PHPMailer vs. Transactional Email Service vs. SMTP

分類Dev

Read file and send contents via Email using Spring Integration

分類Dev

how to send a html email with attached file using JavaMail

Related 関連記事

  1. 1

    How to send cc and bcc recipients in Laravel 7?

  2. 2

    Indy SMTP服务器-如何检测CC和BCC收件人?

  3. 3

    How do I schedule an email to send at a certain time using cron and smtp, in python?

  4. 4

    How to send email in Linux shell script using SMTP without providing the password?

  5. 5

    PHPMailer Mass mailing using BCC and catching not successfull email addressses

  6. 6

    Sending email using luasocket smtp and ssl

  7. 7

    Cannot send email using PHPMailer

  8. 8

    send data using ajax and then send email

  9. 9

    Can I authenticate SMTP using SwiftMailer without sending an email

  10. 10

    Sending email from asp.net using Gmail SMTP OAUTH

  11. 11

    Conditional execution of a PHP script to send email

  12. 12

    How to configure a server to send email using cPanel?

  13. 13

    Using Django to send Email to a User at a scheduled time

  14. 14

    How to send email with multiple attachments using this code

  15. 15

    Send an HTML email using the Gmail API

  16. 16

    PL/SQL - Send cyrillic characters using utl_smtp

  17. 17

    How do I tell Prometheus' Alertmanager to send email through Gmail's SMTP server

  18. 18

    Outlook VBA Auto BCC - Multiple Email Accounts

  19. 19

    Add arguments cc and bcc blackberry.invoke.MessageArguments in javascript

  20. 20

    AWS - PHP form to send email - doesn't send email to same domain

  21. 21

    Codeigniterの電子メールライブラリ、send()メソッドでのcc、bcc値へのアクセス方法

  22. 22

    電子メールの送信時にテストが失敗する:メッセージを送信するにはSMTP宛先アドレスが必要です。メッセージsmtp_envelope_to、to、cc、またはbccアドレスを設定します

  23. 23

    メッセージを送信するには、SMTP宛先アドレスが必要です。メッセージsmtp_envelope_to、to、cc、またはbccアドレスを設定します

  24. 24

    2019 PHPMailer 6.07 / PHP Scrip How to send an email working example

  25. 25

    PHP Mailer shows no errors but doesn't send the email

  26. 26

    How to send notification automatically to logged in user secondary email address in php?

  27. 27

    PHP Mail()/ PHPMailer vs. Transactional Email Service vs. SMTP

  28. 28

    Read file and send contents via Email using Spring Integration

  29. 29

    how to send a html email with attached file using JavaMail

ホットタグ

アーカイブ