/** * wb::mail() * * @param string $sFromAddress * @param string $toAddress, comma sepated list of adresses * @param string $sSubject * @param string $sMessage * @param string $sFromname * @param string $toName * @param string $sReplyTo * @param string $sReplyToName * @param string $sMessagePath * @param array $aAttachment=array ( * 'File to the attachment', * ) * @return */ public function mail($sFromAddress, $toAddress, $sSubject, $sMessage, $sFromname = '', $toName = '', $sReplyToAddress = '', $sReplyToName = '', $sMessagePath = '', $aAttachment = null) { // Strip breaks and trim $sFromAddress = trim(preg_replace('/[\\r\\n]/', '', $sFromAddress)); $toAddress = trim(preg_replace('/[\\r\\n]/', '', $toAddress)); $sSubject = trim(preg_replace('/[\\r\\n]/', '', $sSubject)); $sReplyToAddress = trim(preg_replace('/[\\r\\n]/', '', $sReplyToAddress)); // sanitize parameter to prevent injection $sRecipient = preg_replace("/[^a-z0-9 !?:;,.\\/_\\-=+@#\$&\\*\\(\\)]/im", "", $sFromname); $sFromname = preg_replace("/(content-type:|bcc:|cc:|to:|from:)/im", "", $sRecipient); $sMessage = preg_replace("/(content-type:|bcc:|cc:|to:|from:)/im", "", $sMessage); // create PHPMailer object and define default settings $myMail = new wbmailer(); $html = nl2br($sMessage); $plain = $myMail->html2text($html); // convert commaseperated toAdresses List to an array $aToAddress = $myMail->parseAddresses($toAddress, false); // set user defined from address if ($sFromAddress != '') { //Set who the message is to be sent from $myMail->setFrom($sFromAddress, $sFromname); $sReplyToAddress = $sReplyToAddress == '' ? $sFromAddress : $sReplyToAddress; // convert commaseperated toAdresses List to an array $aReplyToAddress = $myMail->parseAddresses($sReplyToAddress, false); foreach ($aReplyToAddress as $replyToAddr) { // TO: $myMail->addReplyTo($replyToAddr['address']); } foreach ($aToAddress as $toAddr) { // TO: $myMail->AddAddress($toAddr['address']); } } //Set the subject line $myMail->Subject = $sSubject; $myMail->wrapText($html, 80); //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $myMail->msgHTML($html, $sMessagePath, true); if (is_array($aAttachment)) { foreach ($aAttachment as $sFile) { $myMail->AddAttachment($sFile); } } if ($myMail->getReplyToAddresses()) { } //send the message, check for errors return $myMail->Send(); }
function mail($toaddress, $subject, $message, $fromname = '', $replyto = '') { $toArray = explode(',', $toaddress); $fromaddress = $toArray[0]; $myMail = new wbmailer(); // set user defined from address if ($fromaddress != '') { if ($fromname != '') { $myMail->FromName = $fromname; } // FROM-NAME $myMail->From = $fromaddress; // FROM: } if ($replyto != '') { $myMail->AddReplyTo($replyto); // REPLY TO: } // define recepient and information to send out foreach ($toArray as $toAddr) { // TO: $myMail->AddAddress($toAddr); } $myMail->Subject = $subject; // SUBJECT $myMail->Body = $message; // CONTENT (HTML) $textbody = strip_tags($message); $textbody = str_replace("\t", "", $textbody); while (strpos($textbody, "\n\n\n") !== false) { $textbody = str_replace("\n\n\n", "\n\n", $textbody); } while (strpos($textbody, "\r\n\r\n\r\n") !== false) { $textbody = str_replace("\r\n\r\n\r\n", "\r\n\r\n", $textbody); } $myMail->AltBody = $textbody; // CONTENT (TEXT) foreach ($this->attachements as $filename => $file) { $myMail->AddAttachment($file, $filename); } // check if there are any send mail errors, otherwise say successful if (!$myMail->Send()) { return false; } else { return true; } }
$hulp = "rerouted from" . ($row['note'] > 1) ? "(>1)" . $row['email'] : "(=1)" . $regelsArr['post_mail']; $regelsArr['tekst'] = $hulp . "<br />" . $regelsArr['tekst']; } else { if ($row['note'] > 1) { $MassMail->AddAddress($row['email']); // Add a "To" address. $row['email'] } else { $MassMail->AddAddress($regelsArr['post_mail']); } } $MassMail->Body = $regelsArr['tekst']; // Clients that can read HTML will view the normal Body. $MassMail->AltBody = strip_tags($regelsArr['tekst']); // This body can be read by mail clients that do not have HTML email if (isset($_FILES["userfile"]["name"]) && $_FILES["userfile"]["name"] !== "") { $MassMail->AddAttachment($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"], 'base64', $_FILES["userfile"]["type"]); // Add an attachment from a path on the filesystem. } $MassMail->IsHTML(true); if (!$MassMail->Send()) { $regelsArr['toegift'] .= 'Message was not sent.'; $regelsArr['toegift'] .= 'Mailer error: ' . $MassMail->ErrorInfo; } else { if ($debug) { } else { $mail_post = 'MAIL'; // if ($row['note']==1) $mail_post= 'POST'; $updatequery[] = "UPDATE `" . $regelsArr['table_adres'] . "` SET `aant` = '" . $regelsArr['today'] . "|" . $H3 . "|" . $mail_post . "|" . $row['aant'] . "' WHERE `id` = " . $row['id']; } } }