I have a from with an onAfterInsert event with the following code where I’m trying to send results of a field lookup to an array for mail_to:
/**
* Send an email with attachment
*/
// Email parameters
$mail_smtp_server = 'mail.xxx.com'; // SMTP server name or IP address
$mail_smtp_user = 'admin'; // SMTP user name
$mail_smtp_pass = 'admin'; // SMTP password
$mail_from = 'admin@xxx.com'; // From email
$emails_roster = array('[mail_to]');
$mail_to = $emails_roster;
$mail_subject = 'Test message'; // Message subject
$mail_message = 'This is a test message.'; // Message body
$mail_format = 'H'; // Message format: (T)ext or (H)tml
// Send email
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_format);
I have a field as type multiple select and another field with this query:
select email from employees where emp_id = {roster}
Employees selected in the multiple select field are ajax reloaded into another field that show people email address who are on the right side of the multi select. That works great and I can send emails to multiple recipients with an array. However to use the array I have to hard code the email addresses in. What I need it to push the email values retrieved from the filed pulling them from the multi select and send mail. This way mail is sent to only who ever I choose and not whoever happens to be hard coded in. I’ve tried using the {field} and now I’m saving the field as a variable to [mail_to]. Not too good with the PHP and there are more PHP array functions than I can shake a stick at. Anyone know how to achieve this? I may have been vague so if more info is needed let me know.