Add bcc field to mail forms

@asmecher

I am trying to add bcc: field to mail forms (e.g Unassign Reviewer form). I can add input form field in templates, and than find appropriate handler, but I can’t find where form data is passed to mail object.

Also I have found addBcc and setBcc methods in mail class.

Can you give me some hints to make this work?

Hi @Dragoljub_Djordjevic,

The classes that implement email sending/templates (from child class to parent class) are:

classes/mail/ArticleMailTemplate.inc.php
lib/pkp/classes/mail/SubmissionMailTemplate.inc.php
lib/pkp/classes/mail/MailTemplate.inc.php
lib/pkp/classes/mail/Mail.inc.php

The “Unassign Reviewer” form is implemented in lib/pkp/controllers/grid/users/reviewer/form/UnassignReviewerForm.inc.php, which extends lib/pkp/controllers/grid/users/reviewer/form/ReviewerNotifyActionForm.inc.php.

You’ll see the actual mapping from one of our objects to the PHPMailer in Mail.inc.php.

Regards,
Alec Smecher
Public Knowledge Project Team

Made it, thank you :wink:

Hi @Dragoljub_Djordjevic,

Great! If this is something you think would be useful to the community, consider sending back a pull request… This feature has been requested by the community. Add recipient control on email forms · Issue #743 · pkp/pkp-lib · GitHub

Regards,
Alec Smecher
Public Knowledge Project Team

Well, I think it should be modified to comply ojs standards. I’ll just leave a hint here, for Email reviewer form. Other forms can be easily modified in similar way.

In file lib/pkp/templates/controllers/grid/users/reviewer/form/emailReviewerForm.tpl

add:

<input style = "width: 50%" type="email" name="ccAddress" value="" placeholder="Cc:">
<input style="margin-top: 5px; margin-bottom: 15px; width:50%" type="email" name="bccAddress" value="" placeholder="Bcc:">

after email.to field
(this should be rewritten in smarty style and get rid of inline css)

In file lib/pkp/controllers/grid/users/reviewer/form/EmailReviewerForm.inc.php
on line 42 modify function readInputData()

function readInputData() {
$this->readUserVars(array(
‘subject’,
‘message’,
‘bccAddress’,
‘ccAddress’,
));
}

and in same file, function execute($submission) add

	$email->addCc($this->getData('ccAddress'));
	$email->addBcc($this->getData('bccAddress'));

after line

$email->setReplyTo($fromUser->getEmail(), $fromUser->getFullName());

That should be it.