#
#
# email_report()
#
#
# include "templates.util.base_util";
subroutine(email_report(
node email_info,
string report_content), (
debug_message("\n\n#### email_report() START \n");
debug_message("\n" . node_as_string(email_info) . "\n");
# Invoked from command_line_report.cfv and from dynamic reports
# email_info contains all email paramters. At this point we don't have
# to check for valid email paramters, they have already been validated.
# The node volatile.mime_images_buffer should be already set,
# it has been populated in assemble_static_report.cfv
debug_message("#### Final volatile.mime_images_buffer START \n". volatile.mime_images_buffer . "\n");
debug_message("#### Final volatile.mime_images_buffer END \n");
debug_message("#### report_content START \n" . report_content . "\n");
debug_message("#### report_content END \n");
string smtp_server = @email_info{"smtp_server"};
string smtp_username = @email_info{"smtp_username"};
string smtp_password = @email_info{"smtp_password"};
string return_address = @email_info{"return_address"};
string to_address = @email_info{"recipient_address"};
string cc_address = @email_info{"cc_address"};
string bcc_address = @email_info{"bcc_address"};
string report_email_subject = get_expanded_string(@email_info{"report_email_subject"});
string comment = @email_info{"comment"};
# Note, recipient_address, cc_address and bcc_address may contain multiple
# email addresses seperated by a comma.
string all_recipient_addresses = "";
string message = "From: " . return_address . "\n";
if (to_address ne "") then (
message .= "To: " . to_address . "\n";
all_recipient_addresses .= to_address . ",";
);
if (cc_address ne "") then (
message .= "Cc: " . cc_address . "\n";
all_recipient_addresses .= cc_address . ",";
);
if (bcc_address ne "") then (
message .= "Bcc: " . bcc_address . "\n";
all_recipient_addresses .= bcc_address . ",";
);
all_recipient_addresses = replace_last(all_recipient_addresses, ",", "");
message .= "Subject: " . report_email_subject . "\n";
message .= "\n";
debug_message("\n" . node_as_string(email_info) . "\n");
debug_message("#### Email header\n: " . message . "\n\n");
if (comment ne "") then (
# Insert the comment into the report_content string by replacing
# the body element.
# Maintain line breaks
if (contains(comment, "\n")) then (
comment = replace_all(comment, "\n", "
");
);
string comment_as_html = '