Skip to content
Snippets Groups Projects
Commit 5d809f85 authored by Leonardo Alain Surdez's avatar Leonardo Alain Surdez
Browse files

[Merge] branch 'feature/bcc' into 'master'

[Feat] Rewrite BCC and recipient

See merge request !28
parents 7a2676c7 de36748a
No related branches found
No related tags found
1 merge request!28[Feat] Rewrite BCC and recipient
......@@ -18,17 +18,34 @@ class MailsController extends Controller
public function mailApplicant()
{
// @TODO: Change every email hard written here as env vars!
$headers = array(
// 'Content-Type' => 'text/html',
// 'charset'=>'UTF8',
'From' => 'noreply+candidatureApprentis@epfl.ch',
'Bcc' => 'formation.apprentis@epfl.ch',
'Reply-To' => 'formation.apprentis@epfl.ch',
'X-Mailer' => 'PHP/' . phpversion()
);
// Prefix the mail subject with the environment value when we are not in PROD!
// Redefine the Bcc mail when not in prod
$subject = $this->request->input('subject');
if ('prod' !== getenv('ENVIRONMENT')) {
$subject = "[". getenv('ENVIRONMENT') ."] " . $subject;
$headers['Bcc'] = "canap-ops@groupes.epfl.ch";
}
foreach ($this->request->input('recipients') as $key => $recipient) {
$content = str_replace("[METIER]", $this->request->input('jobs')[$key], $this->request->input('content'));
mail($recipient, $this->request->input('subject'), $content, $headers);
// Change the recipient to canap-ops@groupes.epfl.ch when not in PROD!
if ('prod' !== getenv('ENVIRONMENT')) {
$content = "RECIPIENT OF THIS MAIL HAS BEEN REWRITTEN\nOriginal recipient was: " . $recipient . "\n\n" . $content;
$recipient = "canap-ops@groupes.epfl.ch";
}
mail($recipient, $subject, $content, $headers);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment