Page 1 of 1

PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 25. November 2021 08:04
by zahidaliayub
Hello!
We can put any generic value into the each message but how can we put their own BCC Email address
into each of their own Message.

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "Bcc: developers@gmail.com" . "\r\n";

$message = "
<html>
<body>
Hello $_GET['Bcc'] ;
Its a test message.

</body>
</html>
";

mail($to,$subject,$message,$headers);

thanks

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 25. November 2021 08:19
by Altrea
Hi,

Like every other variable content you want to use multiple times, put it in a variable first.
Thats PHP / programming 101 knowledge.

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 25. November 2021 08:26
by zahidaliayub
Altrea wrote:Hi,

Like every other variable content you want to use multiple times, put it in a variable first.
Thats PHP / programming 101 knowledge.


if you read the message i asked how to put BCC into each Message.

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 25. November 2021 10:28
by Nobbie
The question is, how to determine "the own mail address". As you do not specify any From : sender in your mail() function call, the system uses the configuration of the sendmail configuration or of the SMTP server which is specified in php.ini

But this is NOT evaluated by PHP, the physical sending of the mail is done by the corresponding mail server and an address of the sender is applied by that mail server. You cannot easily evaluate the mail configuration in your PHP script.You can only specify your own From: clause in the 5th parameter of mail(), which overrides the default of the mail server and finally apply the same value to Bcc:

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 25. November 2021 11:32
by Altrea
I read the message, but probably i don't understand it.

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 27. November 2021 15:28
by zahidaliayub
Nobbie wrote:The question is, how to determine "the own mail address". As you do not specify any From : sender in your mail() function call, the system uses the configuration of the sendmail configuration or of the SMTP server which is specified in php.ini

But this is NOT evaluated by PHP, the physical sending of the mail is done by the corresponding mail server and an address of the sender is applied by that mail server. You cannot easily evaluate the mail configuration in your PHP script.You can only specify your own From: clause in the 5th parameter of mail(), which overrides the default of the mail server and finally apply the same value to Bcc:



Actually let get it understood that all To From Email Values has been passed and SMTP Mail Server on Port 25 is working fine... Emails TO: to@gmail.com From: from@mydomain.com Bcc: bcc1@gmail.com, bcc2@gmail.com had receive successfully mails. Now, I again repeating:

The same Message would be derived to the all recements. I want to add in each recipients' Message should be contained their own Email Address

How?

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 27. November 2021 17:00
by Nobbie
Obviously, you did not understand my answer. Which part is unclear? As i said, you CANNOT evaluate the own email address in PHP, if you do not apply it via From: clause. The only way is to apply your own address via From: clause and also apply it to Bcc:.

Got it now?

Example:

$myaddress = "myemail@mydomain.com";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "Bcc: $myaddress" . "\r\n";

$from = "From: $myaddress";

$message = "
<html>
<body>
Hello $_GET['Bcc'] ;
Its a test message.

</body>
</html>
";

mail($to,$subject,$message,$headers,$from);

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 28. November 2021 03:02
by zahidaliayub
Nobbie wrote:Obviously, you did not understand my answer. Which part is unclear? As i said, you CANNOT evaluate the own email address in PHP, if you do not apply it via From: clause. The only way is to apply your own address via From: clause and also apply it to Bcc:.

Got it now?

Example:

$myaddress = "myemail@mydomain.com";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "Bcc: $myaddress" . "\r\n";

$from = "From: $myaddress";

$message = "
<html>
<body>
Hello $_GET['Bcc'] ;
Its a test message.

</body>
</html>
";

mail($to,$subject,$message,$headers,$from);



My Question was:
Actually let get it understood that all To From Email Values has been passed and SMTP Mail Server on Port 25 is working fine... Emails TO: to@gmail.com From: from@mydomain.com Bcc: bcc1@gmail.com, bcc2@gmail.com had receive successfully mails. Now, I again repeating:

The same Message would be derived to the all recements. I want to add in each recipients' Message should be contained their own Email Address



You should not waist my Time I didn't write in any other language but ENGLISH. You every time trying to Teach me Syntex of mail() function. I know all what you trying to teach. If you do not want to answer do not reply.
I think you are cannot understand English!
Please do not answer otherwise other Developers would not answer my question do not try to make trash box.

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 28. November 2021 03:07
by zahidaliayub
Altrea wrote:I read the message, but probably i don't understand it.



Actually let get it understood that all To From Email Values has been passed and SMTP Mail Server on Port 25 is working fine... Emails TO: to@gmail.com From: from@mydomain.com Bcc: bcc1@gmail.com, bcc2@gmail.com had receive successfully mails. Now, I again repeating:

The same Message would be derived to the all recements. I want to add in each recipients' Message should be contained their own Email Address

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 28. November 2021 03:39
by Altrea
WE are wasting YOUR time?
You might write in english, but your words doesn't make any sense to me.

I want to add in each recipients' Message should be contained their own Email Address

What does that mean? Can you give us an example?

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 28. November 2021 04:04
by zahidaliayub
Altrea wrote:WE are wasting YOUR time?
You might write in english, but your words doesn't make any sense to me.

I want to add in each recipients' Message should be contained their own Email Address

What does that mean? Can you give us an example?


$_GET["Bcc"] = " bcc1@gmail.com,bcc2@gmail.com,bcc3@gmail.com";

$to = "To: to@gmail.com";
$from = "from@gmail.com";
$bcc = $_GET["Bcc"];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

$headers .= "From: $from" . "\r\n";
$headers .= "Cc: $cc" . "\r\n";

$headers .= "Bcc: $bcc" . "\r\n";

$eachone = explode(",", $_GET["Bcc"]);


$message = "
<html>
<body>
Hello $eachone[1];
Its a test message.
thanks
</body>
</html>
";

mail($to,t$subject,$message,$headers);


Recipient should receive!

Hello bcc2@gmail.com,
Its a test message.
thanks

while message of others should be:

Hello to@gmail.com
Its a test message.
thanks

Hello from@gmail.com
Its a test message.
thanks

Hello bcc1@gmail.com
Its a test message.
thanks

Hello bcc3@gmail.com
Its a test message.
thanks


etc.

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 28. November 2021 09:42
by Altrea
now its clear. You want a personalized salutation for each recipiant.
That is technically not possible. That is not how emails are working (at least not by sending a single email).

What you maybe want to use is a mass mailing script, which would send multiple mails (one for each recipiant). Then it is for sure possible to place the personalized salutation before the email is sent.

Re: PHP SMTP : each Bcc <email> into their own email Message

PostPosted: 28. November 2021 11:48
by Nobbie
I can understand english very well, but your english is no english. But that is not the main problem, obviously you cannot explain the goal of your project precisely. Your question is a total mess. Last not least you are wasting our time. And last not least there is no way to send personalized messages with only one body. You would need to have kind of JavaScript or similar in Email bodys to achive that, but there is no such thing as email clients dont know any script languages. You can only send static text.

P.S.: The confusion comes due to your poor english in conjunction with your wording. The whole email thing is a message, but what you are looking for is called email body. Nobody calls it message (besides you).