How to add Bcc in mail

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

How to add Bcc in mail

Post by RonP » 2019-04-28 15:54

Hi,

I like to put a Bcc into a mail function. I haven’t find an example for this yet.
How can I make this work?

Thanks in advance

Ron

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: How to add Bcc in mail

Post by RonP » 2019-05-08 06:57

Hi There,
Someone a hint for me?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to add Bcc in mail

Post by jsetzer » 2019-05-08 07:48

Hi,

AppGini's sendMail-function in incFunction.php does not support CC or BCC, yet (Ver. 5.75), allthough the PHPMailer class being used, does. I have asked Ahmed to support CC and BCC. I think it's on his roadmap.

In between I have solved it this way:
  1. Copy the sendMail-function from incFunction.php
  2. Paste it in one of your PHP files and give it a different name (important!), for example sendMailEx
  3. Check the PHPMailer documentation here:
    https://github.com/PHPMailer/PHPMailer
  4. Change the new sendMailEx-function:
    below...

    Code: Select all

    $pm->addAddress($mail['to'], $mail['name']);
    
    ...add something like...

    Code: Select all

    if ($mail['bcc]) $pm->addBCC($mail['bcc']);
    if ($mail['cc']) $pm->addCC($mail['cc']);
    
  5. In your calling function, add the BCC recipient to your $mail-array like this:

    Code: Select all

    $mail['bcc'] = "[email protected]";
    
  6. Now you can call the new sendMailEx-function:

    Code: Select all

    sendMailEx($mail);
    
That should do the trick for now. Hope this helps!

Best,
Jan

PS: If you need more than one bcc- or cc-recipient, you can for example add a comma-separated list like this... ...and in your sendMailEx-function, split the string using PHP explode-function (https://www.php.net/manual/de/function.explode.php) and add each address using $pm->addCC($item);
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: How to add Bcc in mail

Post by RonP » 2019-05-09 07:08

Hi Jan,
Thanks for the answers. As I"m not that familiar with PHP, I"ll give it a try.
I"m off the street now for a while :D
Ron

Post Reply