nuSendEmail(): Pass an array
Posted: Tue Sep 27, 2022 5:01 pm
Instead of passing parameters to nuSendEmail like this:
nuSendEmail('to@test.com','from@test.com','From','Content','Subject', [], true, 'cc_email@test.com', 'bcc_email@test.com')
Pass them using an array:
Or with a minimal set of arguments:
The main advantage of "named" arguments is that we can pass the arguments out of their positional order.
Simply put, we don't have to remember the order of parameters.
They also increase the readability of the code.
nuSendEmail('to@test.com','from@test.com','From','Content','Subject', [], true, 'cc_email@test.com', 'bcc_email@test.com')
Pass them using an array:
Code: Select all
nuSendEmail(array(
'to' => 'to@test.com',
'cc' => 'cc_email@test.com',
'bcc' => 'bcc_email@test.com',
'from_email' => 'from@test.com',
'from_name' => 'From',
'body' => 'Content',
'subject' => 'Subject',
'attachments' => [] ,
'html' => true,
'reply_to' => [] ,
'priority' => "3"
));
Code: Select all
nuSendEmail(array(
'to' => 'to@test.com',
'cc' => 'cc_email@test.com',
'bcc' => 'bcc_email@test.com',
'body' => 'Content',
'subject' => 'Subject'
));
The main advantage of "named" arguments is that we can pass the arguments out of their positional order.
Simply put, we don't have to remember the order of parameters.
They also increase the readability of the code.