33 function __construct() {
40 #----------------------------------------- 41 # EDITABLE CONFIGURATION VARIABLES 43 $this->header =
""; # any headers, delimited with semi-colon
44 $this->mailto =
"cuerror@homecu.net"; # recipient
id 45 $this->hideto =
false; #
if true, to is bcc instead of to
46 $this->mailfrom =
"noreply@homecu.net"; #
default sender
id ** NOTE: This should be JUST an email address with NO NAME somebody@email.com NOT
"SomeBody" <somebody@email.com>
47 $this->mailfromname =
'';
50 $this->subject =
"Digital Banking Message"; #
default subject
51 $this->msgbody =
""; #
default empty message
52 $this->htmlMsgbody =
"";
53 $this->plainMsgbody =
"";
54 $this->executeQuietly =
false;
58 $this->script = HCU_array_key_value(
"SCRIPT_NAME", $_SERVER); # What script?
59 $this->server = HCU_array_key_value(
"SERVER_NAME", $_SERVER); # What Server?
60 $this->query = HCU_array_key_value(
"REQUEST_URL", $_SERVER); # How was it called
61 $this->errdate = `date +
"%a, %d %b %Y %T %Z"`;
63 #------------------------------------------ 71 # Goal is to default it with a script with more generalized functionality 72 # added in sendSESEmailBulk.py script 74 return dirname(__FILE__) .
"/../scripts/sendSESEmailBulk.py";
76 return dirname(__FILE__) .
"/../scripts/sendSESEmail.py";
90 $context[
"cucode"] = $this->cu;
91 $context[
"callingScript"] = $this->file;
92 $context[
"callingFunction"] = $this->callingfunction;
93 $context[
"serverName"] = $this->server;
94 $context[
"ServerScript"] = $this->script;
96 return HCU_JsonEncode($context);
115 $from = $this->mailfromname !=
'' ?
"{$this->mailfromname} <{$this->mailfrom}>" : $this->mailfrom;
116 $fromString =
"--efrom " . escapeshellarg($from);
119 $replyToString = $this->replyto !=
"" ?
"--replyto " . escapeshellarg($this->replyto) :
"";
122 $subjectString =
"--subject " . escapeshellarg($this->subject);
128 if ($this->htmlMsgbody !=
"") {
129 $htmlTextBody = $this->htmlMsgbody;
131 if ($this->plainMsgbody !=
"") {
132 $plainTextBody = $this->plainMsgbody;
134 if ($this->msgbody !=
"") {
135 if (trim(strtolower($this->header)) ==
"content-type: text/html") {
136 $htmlTextBody = $this->msgbody;
138 $plainTextBody = $this->msgbody;
143 $plainTextString =
"";
144 $htmlTextString =
"";
145 if ($plainTextBody !=
"") {
147 $plainTextBody = str_replace(
"\n",
"\\n", str_replace(
"\r\n",
"\\r\\n", $plainTextBody));
148 $plainTextString =
"--plaintext \"`echo " . escapeshellarg($plainTextBody) .
"`\"";
150 if ($htmlTextBody !=
"") {
152 $htmlTextString =
"--htmltext " . escapeshellarg($htmlTextBody);
155 if ($plainTextString ==
"" && $htmlTextString ==
"") {
156 $plainTextString =
"--plaintext ''";
160 $toArray = is_array($this->mailto) ? $this->mailto : explode(
";", str_replace(
",",
";", strval($this->mailto)));
161 $toSwitch = $this->hideto ?
"--bcc" :
"--to";
162 $executeQuietly = $this->executeQuietly ?
"--quiet" :
"";
165 $toArray = array_map(
"trim", $toArray);
166 $toArray = array_map(
"escapeshellarg", $toArray);
168 $toString =
"$toSwitch " . implode(
" ", $toArray);
172 $cmd =
"(python3 $pyFile $toString $fromString $subjectString $plainTextString \ 173 $htmlTextString $replyToString $executeQuietly $awsSesLoggingContext) > /dev/null &";
185 $pyFile = $this->pyFile;
188 $msg .=
"Error in $this->script on Server $this->server\\n";
189 $msg .=
"Called as $this->query\\n\\n";
190 $msg .= $this->line ==
"" ?
"" :
"LINE: $this->line\\n";
191 $msg .= $this->file ==
"" ?
"" :
"FILE: $this->file\\n";
192 $msg .= $this->error ==
"" ?
"" :
"ERROR: $this->error\\n";
193 $msg .= $this->sql ==
"" ?
"" :
"SQL: $this->sql\\n";
194 $msg .= $this->cu ==
"" ?
"" :
"CU: $this->cu\\n";
195 $msg .= $this->member ==
"" ?
"" :
"MEMBER: $this->member\\n";
199 $plainTextString =
"--plaintext \"`echo " . escapeshellarg($msg) .
"`\"";
202 $subject =
"Error in $this->script";
203 $subjectString =
"--subject " . escapeshellarg($subject);
206 $fromString =
"--efrom " . escapeshellarg($this->mailfrom);
209 $toArray = is_array($this->mailto) ? $this->mailto : explode(
";", str_replace(
",",
";", strval($this->mailto)));
210 $toSwitch = $this->hideto ?
"--bcc" :
"--to";
215 foreach($toArray as $toEmail) {
216 if (trim($toEmail) !=
"") {
217 $toList[] = escapeshellarg($toEmail);
219 if (count($toList) >= 50) {
220 $toString =
"$toSwitch " . implode(
" ", $toList);
221 $cmd =
"(python3 $pyFile $toString $fromString $subjectString $plainTextString $awsSesLoggingContext) &";
228 $toString =
"$toSwitch " . implode(
" ", $toList);
229 $cmd =
"(python3 $pyFile $toString $fromString $subjectString $plainTextString $awsSesLoggingContext) &";
getAwsSesLoggingContextJsonString()