Refactor email activity creation
This refactors how email activities are created to fix some bugs and allow it to work better with extensions like https://lab.civicrm.org/extensions/msgtplblocker
- Make sure we always have a
source_contact_id
set to create an activity (otherwise it will fail). - Create the activity before sending the email - otherwise you can have a situation that an email sent but then something crashed before the activity could be created and it looks like no email was sent.
- Move the email activity creation code into it's own class so the main "send" function is cleaner.
- Add CC/BCC information to the email activity so we can see if it was CC/BCC'd.