/** * Simple plain string attachment test. */ function test_Plain_StringAttachment() { $this->Mail->Body = "Here is the text body"; $this->Mail->Subject .= ": Plain + StringAttachment"; $sAttachment = "These characters are the content of the " . "string attachment.\nThis might be taken from a " . "database or some other such thing. "; $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); $this->BuildBody(); $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); }
function send() { $conf = $this->smtp; $mail = new PHPMailer(); $mail->IsSMTP(false); //$mail->Host = $conf['host']; //$mail->SMTPAuth = true; $mail->IsHTML(true); //$mail->SMTPDebug = 2; //$mail->Port = $conf['port']; //$mail->Username = $conf['user']; //$mail->Password = $conf['pass']; //$mail->SMTPSecure = 'tls'; $mail->setFrom($this->from, 'Onboarding Mail'); $mail->addReplyTo($this->from, 'Onboarding Mail'); $mail->addAddress($this->to); foreach ($this->attachment as $k => $att) { $num = $k + 1; $fname = "Events{$num}_" . date('h:i:s') . ".ics"; $mail->AddStringAttachment($att, $fname, 'base64', 'text/ics'); } $mail->Subject = $this->subject; $mail->Body = $this->bodyText; if (!$mail->send()) { echo '<pre>'; echo 'Message could not be sent.<br>'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } }
function wpsight_mail_send_email($data = array(), $opts = array()) { if (!class_exists('PHPMailer')) { require ABSPATH . '/wp-includes/class-phpmailer.php'; } $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; foreach ($data['recipients'] as $addr) { if (is_array($addr)) { $mail->AddAddress($addr[0], $addr[1]); } else { $mail->AddAddress($addr); } } $mail->Subject = isset($data['subject']) ? $data['subject'] : null; if (is_array($data['body']) && isset($data['body']['html'])) { $mail->isHTML(true); $mail->Body = $data['body']['html']; $mail->AltBody = isset($data['body']['text']) ? $data['body']['text'] : null; } $mail->From = $data['sender_email']; $mail->FromName = $data['sender_name']; if (isset($data['reply_to'])) { foreach ((array) $data['reply_to'] as $addr) { if (is_array($addr)) { $mail->AddReplyTo($addr[0], $addr[1]); } else { $mail->AddReplyTo($addr); } } } if (isset($data['attachments']) && is_array($data['attachments'])) { foreach ($data['attachments'] as $attachment) { $encoding = isset($attachment['encoding']) ? $attachment['encoding'] : 'base64'; $type = isset($attachment['type']) ? $attachment['type'] : 'application/octet-stream'; $mail->AddStringAttachment($attachment['data'], $attachment['filename'], $encoding, $type); } } if (isset($opts['transport']) && $opts['transport'] == 'smtp') { $mail->isSMTP(); $mail->Host = $opts['smtp_host']; $mail->Port = isset($opts['smtp_port']) ? (int) $opts['smtp_port'] : 25; if (!empty($opts['smtp_user'])) { $mail->Username = $opts['smtp_user']; $mail->Password = $opts['smtp_pass']; } if (!empty($opts['smtp_sec'])) { $mail->SMTPSecure = $opts['smtp_sec']; } } do_action('wpsight_mail_pre_send', $mail, $data, $opts); return $mail->send() ? true : $mail->ErrorInfo; }
/** * sendProof - email out with an attachment the proof data */ function sendProof($attachment, $reviewName, $proofFile) { // TO: // Reviewer Test // Reviewer //$reviewerAddr = '*****@*****.**'; //$reviewerName = 'David Heskett'; $reviewerAddr = '*****@*****.**'; $reviewerName = 'Trish Rose-Sandler'; // FROM: // Automated Proof $fromAutoName = 'Automated Proof'; $fromAutoAddr = '*****@*****.**'; // FILE NAME $filename = 'Proof-' . date('Y-m-d-H-i') . '.csv'; // attachment filename // SUBJECT: $subject = 'Data import PROOF to review for: ' . $reviewName; // ATTACHMENT FILE DATA: // $attachment that is provided // DO EET! $mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch try { // REPLY TO: $mail->AddReplyTo($fromAutoAddr, $fromAutoName); // TO: $mail->AddAddress($reviewerAddr, $reviewerName); // FROM: $mail->SetFrom($fromAutoAddr, $fromAutoName); // SUBJECT: $mail->Subject = $subject; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $linkToProofFile = str_replace('/var/www', 'http:/', $proofFile); // MESSAGE: $msg = 'Here is a <strong>Proof</strong> of <strong>' . $reviewName . '</strong>. <br>See : ' . $linkToProofFile . ' <br><a href="' . $linkToProofFile . '">Proof File Link</a>'; $mail->MsgHTML($msg); // ATTACHMENT: $encoding = '8bit'; $type = 'application/excel'; $mail->AddStringAttachment($attachment, $filename, $encoding, $type); // attachment (generated on the fly, not a disk file) // SEND IT $mail->Send(); //echo "Message Sent OK</p>\n"; $this->proofMailed = true; } catch (phpmailerException $e) { $this->error = $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { $this->error = $e->getMessage(); //Boring error messages from anything else! } }
public function Send(IEmailMessage $emailMessage) { $this->phpMailer->ClearAllRecipients(); $this->phpMailer->ClearReplyTos(); $this->phpMailer->CharSet = $emailMessage->Charset(); $this->phpMailer->Subject = $emailMessage->Subject(); $this->phpMailer->Body = $emailMessage->Body(); $from = $emailMessage->From(); $defaultFrom = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_ADDRESS); $defaultName = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_NAME); $address = empty($defaultFrom) ? $from->Address() : $defaultFrom; $name = empty($defaultName) ? $from->Name() : $defaultName; $this->phpMailer->SetFrom($address, $name); $replyTo = $emailMessage->ReplyTo(); $this->phpMailer->AddReplyTo($replyTo->Address(), $replyTo->Name()); $to = $this->ensureArray($emailMessage->To()); $toAddresses = new StringBuilder(); foreach ($to as $address) { $toAddresses->Append($address->Address()); $this->phpMailer->AddAddress($address->Address(), $address->Name()); } $cc = $this->ensureArray($emailMessage->CC()); foreach ($cc as $address) { $this->phpMailer->AddCC($address->Address(), $address->Name()); } $bcc = $this->ensureArray($emailMessage->BCC()); foreach ($bcc as $address) { $this->phpMailer->AddBCC($address->Address(), $address->Name()); } if ($emailMessage->HasStringAttachment()) { Log::Debug('Adding email attachment %s', $emailMessage->AttachmentFileName()); $this->phpMailer->AddStringAttachment($emailMessage->AttachmentContents(), $emailMessage->AttachmentFileName()); } Log::Debug('Sending %s email to: %s from: %s', get_class($emailMessage), $toAddresses->ToString(), $from->Address()); $success = false; try { $success = $this->phpMailer->Send(); } catch (Exception $ex) { Log::Error('Failed sending email. Exception: %s', $ex); } Log::Debug('Email send success: %d. %s', $success, $this->phpMailer->ErrorInfo); }
private function emailAgreement($mem, $pdf) { $primary = \COREPOS\Fannie\API\Member\MemberREST::getPrimary($mem); if (filter_var($primary[0]['email'], FILTER_VALIDATE_EMAIL)) { $mail = new PHPMailer(); $mail->From = '*****@*****.**'; $mail->FromName = 'Whole Foods Co-op'; $mail->AddAddress($primary[0]['email']); $mail->Subject = 'Subscription Agreement'; $mail->Body = 'A copy of your subscription agreement is attached.'; $mail->AddStringAttachment($pdf, 'wfc.pdf', 'base64', 'application/pdf'); $mail->Send(); } }
public function send() { // Create a PHP Mailer object and set it up $mailer = new \PHPMailer(true); $mailer->IsMail(); // Set the emails subject $mailer->Subject = $this->subject; // Set the from address if (!empty($this->from)) { $mailer->SetFrom($this->from['email'], $this->from['name'], true); } // Set the to address foreach ($this->to as $to) { $mailer->AddAddress($to['email'], $to['name']); } // cc foreach ($this->cc as $cc) { $mailer->AddCC($cc['email'], $cc['name']); } // bcc foreach ($this->bcc as $bcc) { $mailer->AddBCC($bcc['email'], $bcc['name']); } // If we have an HTML body, set that on the message // and mark it as an HTML email if (!empty($this->htmlBody)) { $mailer->Body = $this->htmlBody; $mailer->AltBody = $this->textBody; $mailer->IsHTML(); } else { $mailer->Body = $this->textBody; } // Attachments foreach ($this->attachments as $attachment) { $mailer->AddStringAttachment($attachment['content'], $attachment['filename'], 'base64', $attachment['mime']); } // Finally, try and send teh message return $mailer->Send(); }
function exitcron() { global $log; global $config; if ($config['sendnotification'] && filter_var($config['adminemail'], FILTER_VALIDATE_EMAIL)) { require $config['path'] . '/libs/phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer(); if ($config['smtp']) { $mail->isSMTP(); $mail->Host = $config['smtpserver']; $mail->SMTPAuth = true; $mail->Username = $config['smtpusername']; $mail->Password = $config['smtppassword']; $mail->SMTPSecure = $config['smtpsecure']; $mail->Port = $config['smtpport']; } $mail->From = $config['emailfrom']; $mail->FromName = 'CDP.me'; $mail->addAddress($config['adminemail']); $mail->WordWrap = 50; $mail->AddStringAttachment($log, 'log.txt'); $mail->isHTML(true); $mail->Subject = 'CDP.me backup report'; $mail->Body = 'Hello!<br />This is your CDP.me backup report at ' . date(DATE_RFC822) . '.<br/>The backup log is attached.'; $mail->AltBody = 'Hello! This is your CDP.me backup report at ' . date(DATE_RFC822) . '. The backup log is attached.'; if (!$mail->send()) { echo 'Message could not be sent.' . PHP_EOL; echo 'Mailer Error: ' . $mail->ErrorInfo . PHP_EOL; } else { echo 'Message has been sent' . PHP_EOL; } } else { echo $log; } die; }
function emailEvaluation($strEmail, $strName, $PDF, $strFilename) { $strMessage = ' <html> <head> <title>Your Puckstoppers Goaltending Evaluation</title> </head> <body> <p> Hi ' . $strName . ',<br /><br /> Please find attached your Puckstoppers Goaltending Evaluation in PDF format. </p> <p> Hope to see you again soon,<br /> <strong>Puckstoppers</strong> </p> <p> If you have any trouble opening the attachment you may need to download a PDF reader.<br /> You can download one by clicking this link: https://get.adobe.com/reader/ </p> </body> </html> '; $strSubject = 'Your Puckstoppers Goaltending Evaluation'; $email = new PHPMailer(); $email->From = '*****@*****.**'; $email->FromName = 'Puckstoppers'; $email->Subject = $strSubject; $email->Body = $strMessage; $email->IsHTML(true); $email->AddAddress($strEmail); $email->AddBCC('*****@*****.**'); //$email->AddAttachment( $PDF , 'eval.pdf' ); $email->AddStringAttachment($PDF, $strFilename, $encoding = 'base64', $type = 'application/pdf'); return $email->Send(); }
private function sendEmail($to, $subject, $body, $attachment = null) { require 'libraries/PHPMailer/PHPMailerAutoload.php'; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtpout.secureserver.net"; // set the SMTP server $mail->Port = 25; // set the SMTP port $mail->Username = "******"; // SMTP account username $mail->Password = "******"; // SMTP account password $mail->From = "*****@*****.**"; $mail->FromName = "Manawatu Flowers"; if (is_array($to)) { foreach ($to as $partner) { $mail->addAddress($partner); } } else { $mail->addAddress($to); } if (!is_null($attachment)) { $mail->AddStringAttachment($attachment, 'auction-summary_' . date("d-m-Y") . '.pdf', 'base64', 'application/pdf'); } $mail->Subject = $subject; $mail->Body = $body; if (!$mail->send()) { throw new Exception("Mailer Error: " . $mail->ErrorInfo); } return true; }
function sendMail($to, $subject, $msg, $msgFromUrl, $attach, $from, $fromName, $user, $port, $password, $serverSmtp) { if (!filter_var($from, FILTER_VALIDATE_EMAIL)) { return "La dirección de E-mail no es valida. / " . $from; exit; } if ($attach > '0') { $attachData = file_get_contents($attach); } if ($msgFromUrl > '0') { $msg = file_get_contents($msgFromUrl); } require_once "PHPMailer/PHPMailerAutoload.php"; $mail = new PHPMailer(); $mail->IsSMTP(true); $mail->Host = $serverSmtp; $mail->Port = intval($port); $mail->SMTPAuth = true; if ($mail->Port > 25) { $mail->SMTPSecure = 'tls'; } $mail->Username = $user; $mail->Password = $password; $mail->SetFrom($from, $fromName); $mail->AddAddress($to); $mail->SMTPDebug = 0; $mail->CharSet = 'UTF-8'; $mail->IsHTML(true); $mail->Subject = $subject; $mail->MsgHTML($msg); //if($attach>'0'){$mail->AddAttachment($attach);} if ($attach > '0') { parse_str($attach); $fName = str_replace(' ', '_', $subject) . '_' . $id; $mail->AddStringAttachment($attachData, $fName . '.pdf', $encoding = 'base64', $type = 'application/pdf'); } if (!$mail->Send()) { return 'ERROR: ' . $mail->ErrorInfo . ' / FROM:' . $from . ' / TO:' . $to; } else { return 'MENSAJE ENVIADO'; } exit; }
function xmail($to, $from = array(), $topic, $comment, $type = 'plain', $attachment = array()) { global $config, $my, $lang, $bbcode; require_once "classes/mail/class.phpmailer.php"; require_once 'classes/mail/extended.phpmailer.php'; $mail = new PHPMailer(); $mail->CharSet = $lang->phrase('charset'); // Added Check_mail for better security // Now it is not possible to add various headers to the mail if (!isset($from['mail']) || !check_mail($from['mail'])) { $mail->From = $config['forenmail']; } else { $mail->From = $from['mail']; } if (!isset($from['name'])) { $mail->FromName = $config['fname']; } else { $mail->FromName = $from['name']; } if ($config['smtp'] == 1) { $mail->Mailer = "smtp"; $mail->IsSMTP(); $mail->Host = $config['smtp_host']; if ($config['smtp_auth'] == 1) { $mail->SMTPAuth = TRUE; $mail->Username = $config['smtp_username']; $mail->Password = $config['smtp_password']; } } elseif ($config['sendmail'] == 1) { $mail->IsSendmail(); $mail->Mailer = "sendmail"; $mail->Sendmail = $config['sendmail_host']; } else { $mail->IsMail(); } $mail->Subject = $topic; if (!is_array($to)) { $to = array('0' => array('mail' => $to)); } $i = 0; foreach ($to as $email) { if ($type == 'bb') { BBProfile($bbcode); $bbcode->setSmileys(0); $bbcode->setReplace($config['wordstatus']); $row->comment = $row->comment; $mail->IsHTML(TRUE); $mail->Body = $bbcode->parse($comment); $mail->AltBody = $bbcode->parse($comment, 'plain'); } elseif ($type == 'html') { $mail->IsHTML(TRUE); $mail->Body = $comment; $mail->AltBody = html_entity_decode(strip_tags($comment)); } else { $mail->Body = html_entity_decode($comment); } if (isset($email['name'])) { $mail->AddAddress($email['mail'], $email['name']); } else { $mail->AddAddress($email['mail']); } foreach ($attachment as $file) { if ($file['type'] == 'string') { $mail->AddStringAttachment($file['file'], $file['name']); } else { $mail->AddAttachment($file['file'], $file['name']); } } if ($mail->Send()) { $i++; } $mail->ClearAddresses(); $mail->ClearAttachments(); } return $i; }
/** * API function to send e-mail message * @param string $args['fromname'] name of the sender * @param string $args['fromaddress'] address of the sender * @param string $args['toname '] name to the recipient * @param string $args['toaddress'] the address of the recipient * @param string $args['replytoname '] name to reply to * @param string $args['replytoaddress'] address to reply to * @param string $args['subject'] message subject * @param string $args['contenttype '] optional contenttype of the mail (default config) * @param string $args['charset'] optional charset of the mail (default config) * @param string $args['encoding'] optional mail encoding (default config) * @param string $args['body'] message body, if altbody is provided then this * is the HTML version of the body * @param string $args['altbody'] alternative plain-text message body, if * specified the e-mail will be sent as multipart/alternative * @param array $args['cc'] addresses to add to the cc list * @param array $args['bcc'] addresses to add to the bcc list * @param array|string $args['headers'] custom headers to add * @param int $args['html'] HTML flag, if altbody is not specified then this * indicates whether body contains HTML or not; if altbody is * specified, then this value is ignored, the body is assumed * to be HTML, and the altbody is assumed to be plain text * @param array $args['attachments'] array of either absolute filenames to attach * to the mail or array of arays in format * array($string,$filename,$encoding,$type) * @param array $args['stringattachments'] array of arrays to treat as attachments, * format array($string,$filename,$encoding,$type) * @param array $args['embeddedimages'] array of absolute filenames to image files * to embed in the mail * @todo Loading of language file based on Zikula language * @return bool true if successful, false otherwise */ public function sendmessage($args) { // Check for installed advanced Mailer module $event = new GenericEvent($this, $args); $this->dispatcher->dispatch('module.mailer.api.sendmessage', $event); if ($event->isPropagationStopped()) { return $event->getData(); } // include php mailer class file require_once \ZIKULA_ROOT . "/system/Mailer/lib/vendor/class.phpmailer.php"; // create new instance of mailer class $mail = new \PHPMailer(); // set default message parameters $mail->PluginDir = "system/Mailer/lib/vendor/"; $mail->ClearAllRecipients(); $mail->ContentType = isset($args['contenttype']) ? $args['contenttype'] : $this->getVar('contenttype'); $mail->CharSet = isset($args['charset']) ? $args['charset'] : $this->getVar('charset'); $mail->Encoding = isset($args['encoding']) ? $args['encoding'] : $this->getVar('encoding'); $mail->WordWrap = $this->getVar('wordwrap'); // load the language file $mail->SetLanguage('en', $mail->PluginDir . 'language/'); // get MTA configuration if ($this->getVar('mailertype') == 4) { $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = $this->getVar('smtpserver'); // specify server $mail->Port = $this->getVar('smtpport'); // specify port } elseif ($this->getVar('mailertype') == 3) { $mail->IsQMail(); // set mailer to use QMail } elseif ($this->getVar('mailertype') == 2) { ini_set("sendmail_from", $args['fromaddress']); $mail->IsSendMail(); // set mailer to use SendMail $mail->Sendmail = $this->getVar('sendmailpath'); // specify Sendmail path } else { $mail->IsMail(); // set mailer to use php mail } // set authentication paramters if required if ($this->getVar('smtpauth') == 1) { $mail->SMTPAuth = true; // turn on SMTP authentication $mail->SMTPSecure = $this->getVar('smtpsecuremethod'); // SSL or TLS $mail->Username = $this->getVar('smtpusername'); // SMTP username $mail->Password = $this->getVar('smtppassword'); // SMTP password } // set HTML mail if required if (isset($args['html']) && is_bool($args['html'])) { $mail->IsHTML($args['html']); // set email format to HTML } else { $mail->IsHTML($this->getVar('html')); // set email format to the default } // set fromname and fromaddress, default to 'sitename' and 'adminmail' config vars $mail->FromName = isset($args['fromname']) && $args['fromname'] ? $args['fromname'] : System::getVar('sitename'); $mail->From = isset($args['fromaddress']) && $args['fromaddress'] ? $args['fromaddress'] : System::getVar('adminmail'); // add any to addresses if (is_array($args['toaddress'])) { $i = 0; foreach ($args['toaddress'] as $toadd) { isset($args['toname'][$i]) ? $toname = $args['toname'][$i] : ($toname = $toadd); $mail->AddAddress($toadd, $toname); $i++; } } else { // $toaddress is not an array -> old logic $toname = ''; if (isset($args['toname'])) { $toname = $args['toname']; } // process multiple names entered in a single field separated by commas (#262) foreach (explode(',', $args['toaddress']) as $toadd) { $mail->AddAddress($toadd, $toname == '' ? $toadd : $toname); } } // if replytoname and replytoaddress have been provided us them // otherwise take the fromaddress, fromname we build earlier if (!isset($args['replytoname']) || empty($args['replytoname'])) { $args['replytoname'] = $mail->FromName; } if (!isset($args['replytoaddress']) || empty($args['replytoaddress'])) { $args['replytoaddress'] = $mail->From; } $mail->AddReplyTo($args['replytoaddress'], $args['replytoname']); // add any cc addresses if (isset($args['cc']) && is_array($args['cc'])) { foreach ($args['cc'] as $email) { if (isset($email['name'])) { $mail->AddCC($email['address'], $email['name']); } else { $mail->AddCC($email['address']); } } } // add any bcc addresses if (isset($args['bcc']) && is_array($args['bcc'])) { foreach ($args['bcc'] as $email) { if (isset($email['name'])) { $mail->AddBCC($email['address'], $email['name']); } else { $mail->AddBCC($email['address']); } } } // add any custom headers if (isset($args['headers']) && is_string($args['headers'])) { $args['headers'] = explode("\n", $args['headers']); } if (isset($args['headers']) && is_array($args['headers'])) { foreach ($args['headers'] as $header) { $mail->AddCustomHeader($header); } } // add message subject and body $mail->Subject = $args['subject']; $mail->Body = $args['body']; if (isset($args['altbody']) && !empty($args['altbody'])) { $mail->AltBody = $args['altbody']; } // add attachments if (isset($args['attachments']) && !empty($args['attachments'])) { foreach ($args['attachments'] as $attachment) { if (is_array($attachment)) { if (count($attachment) != 4) { // skip invalid arrays continue; } $mail->AddAttachment($attachment[0], $attachment[1], $attachment[2], $attachment[3]); } else { $mail->AddAttachment($attachment); } } } // add string attachments. if (isset($args['stringattachments']) && !empty($args['stringattachments'])) { foreach ($args['stringattachments'] as $attachment) { if (is_array($attachment) && count($attachment) == 4) { $mail->AddStringAttachment($attachment[0], $attachment[1], $attachment[2], $attachment[3]); } } } // add embedded images if (isset($args['embeddedimages']) && !empty($args['embeddedimages'])) { foreach ($args['embeddedimages'] as $embeddedimage) { $ret = $mail->AddEmbeddedImage($embeddedimage['path'], $embeddedimage['cid'], $embeddedimage['name'], $embeddedimage['encoding'], $embeddedimage['type']); } } // send message if (!$mail->Send()) { // message not send $args['errorinfo'] = $mail->IsError() ? $mail->ErrorInfo : __('Error! An unidentified problem occurred while sending the e-mail message.'); LogUtil::log(__f('Error! A problem occurred while sending an e-mail message from \'%1$s\' (%2$s) to (%3$s) (%4$s) with the subject line \'%5$s\': %6$s', $args)); if (SecurityUtil::checkPermission('Mailer::', '::', ACCESS_ADMIN)) { return LogUtil::registerError($args['errorinfo']); } else { return LogUtil::registerError(__('Error! A problem occurred while sending the e-mail message.')); } } return true; // message sent }
function ezTran() { session_start(); $this->status = ''; $this->error = ''; if ($_POST['ezAds-savePot']) { $file = $_POST['potFile']; $str = $_POST['potStr']; header('Content-Disposition: attachment; filename="' . $file . '"'); header("Content-Transfer-Encoding: ascii"); header('Expires: 0'); header('Pragma: no-cache'); ob_start(); print stripslashes(htmlspecialchars_decode($str, ENT_QUOTES)); ob_end_flush(); $this->status = '<div class="updated">Pot file: ' . $file . ' was saved.</div> '; exit(0); } if ($_POST['ezAds-clear']) { $this->status = '<div class="updated">Reloaded the translations from PHP files and MO.</div> '; unset($_SESSION['ezAds-POs']); } if ($_POST['ezAds-mailPot']) { $file = $_POST['potFile']; $str = stripslashes($_POST['potStr']); $str = str_replace("\\'", "'", $str); if (!class_exists("phpmailer")) { require_once ABSPATH . 'wp-includes/class-phpmailer.php'; } $mail = new PHPMailer(); $mail->From = get_bloginfo('admin_email'); $mail->FromName = get_bloginfo('name'); $mail->AddAddress('*****@*****.**', "Manoj Thulasidas"); $mail->CharSet = get_bloginfo('charset'); $mail->Mailer = 'php'; $mail->SMTPAuth = false; $mail->Subject = $file; $mail->AddStringAttachment($str, $file); $pos1 = strpos($str, "msgstr"); $pos2 = strpos($str, "msgid", $pos1); $head = substr($str, 0, $pos2); $mail->Body = $head; if ($mail->Send()) { $this->status = '<div class="updated">Pot file: ' . $file . ' was sent.</div> '; } else { $this->error = '<div class="error">Error: ' . $mail->ErrorInfo . ' Please save the pot file and <a href="http://manoj.thulasidas.com/mail.shtml" target=_blank>contact the author</a></div>'; } } }
$mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail $mail->Port = 465; $email = "*****@*****.**"; $ContactEmail = "*****@*****.**"; $mail->AddAddress($email); $mail->AddCC($ContactEmail); //$mail->AddBCC($ContactEmail2); $mail->Subject = $subject; $mail->IsHTML(false); $mail->AddStringAttachment($doc, $reporttitle, 'base64', 'application/pdf'); $mail->Body = "\nPlease find attached CD4 Results.\n\nAny pending results are still being processed and will be sent to you once they are ready.\n\nNB: Confirm that you have received this mail.\n\nMany Thanks.\n\n--\n\nCD4 Support Team\n\n"; if (!$mail->Send()) { $errorsending = $mail->ErrorInfo; echo $errorsending; } else { $msg = "Email successfully sent"; echo '<script type="text/javascript">'; echo "window.location.href='reports.php?successsave={$msg}'"; echo '</script>'; echo "SUCCESS"; } exit; //============================================================== //============================================================== //==============================================================
function sendEmailWithPDF($userId, $email, $name, $subject, $body) { require_once 'PHPMailer/class.phpmailer.php'; $account = selectAccountByUserId($userId); $doc = generateUserPDF($account->ID); $password = randomPassword(); $mail = new PHPMailer(); $body = "Requested Tan Numbers are attached to the e-mail..\n\n<br /><br />Password:{$password}"; $mail->CharSet = 'UTF-8'; $mail->SetFrom('*****@*****.**', 'SecureCodingTeam6'); //Set the name as you like $mail->SMTPAuth = true; $mail->Host = "smtp.gmail.com"; // SMTP server $mail->SMTPSecure = "ssl"; $mail->Username = "******"; //account which you want to send mail from $mail->Password = "******"; //this is account's password $mail->Port = "465"; $mail->isSMTP(); $user = getSingleUser($userId); $mail->AddAddress($email, $name); $mail->Subject = $subject; $mail->MsgHTML($body); $doc->SetProtection(array('print', 'copy'), $password); $doc = $doc->Output('', 'S'); //Save the pdf file $mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf'); if (!$mail->send()) { return false; } return true; }
//$mail->Mailer = "smtp"; /* @MYSQL_CONNECT("localhost","root","password"); @mysql_select_db("my_company"); $query = "SELECT full_name, email, photo FROM employee WHERE id=$id"; $result = @MYSQL_QUERY($query); while ($row = mysql_fetch_array ($result)) { */ // HTML body // $body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>"; // $body .= "<i>Your</i> personal photograph to this message.<p>"; // $body .= "Sincerely, <br>"; // $body .= "PHPMailer List manager"; // Plain text body (for mail clients that cannot read HTML) // $text_body = "Hello " . $row["full_name"] . ", \n\n"; // $text_body .= "Your personal photograph to this message.\n\n"; // $text_body .= "Sincerely, \n"; // $text_body .= "PHPMailer List manager"; $mail->Body = "textooo"; $mail->AltBody = "textooo"; $mail->AddAddress("*****@*****.**", "*****@*****.**"); $mail->AddStringAttachment("adjuntooooooo", "YourPhoto.jpg"); if (!$mail->Send()) { echo "There has been a mail error sending to " . $row["email"] . "<br>"; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); //}
break; case "pdf": $mime_type = "application/pdf"; break; case "tif": $mime_type = "image/tiff"; break; case "tiff": $mime_type = "image/tiff"; break; default: $mime_type = "binary/octet-stream"; break; } //add an attachment $mail->AddStringAttachment($parts_array["Body"], $file, $encoding, $mime_type); if (function_exists(get_transcription)) { $attachments_array = $mail->GetAttachments(); $transcription = get_transcription($attachments_array[0]); echo "Transcription: " . $transcription; } else { $transcription = ''; } } } } //add the body to the email $body_plain = rip_tags($body); //echo "body_plain = $body_plain\n"; if (substr($body, 0, 5) == "<html" || substr($body, 0, 9) == "<!doctype") { $mail->ContentType = "text/html";
function phorum_smtp_send_messages($data) { $PHORUM = $GLOBALS["PHORUM"]; $addresses = $data['addresses']; $subject = $data['subject']; $message = $data['body']; $num_addresses = count($addresses); $settings = $PHORUM['smtp_mail']; $settings['auth'] = empty($settings['auth']) ? false : true; if ($num_addresses > 0) { try { require_once "./mods/smtp_mail/phpmailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->PluginDir = "./mods/smtp_mail/phpmailer/"; $mail->CharSet = $PHORUM["DATA"]["CHARSET"]; $mail->Encoding = $PHORUM["DATA"]["MAILENCODING"]; $mail->Mailer = "smtp"; $mail->IsHTML(false); $mail->From = $PHORUM['system_email_from_address']; $mail->Sender = $PHORUM['system_email_from_address']; $mail->FromName = $PHORUM['system_email_from_name']; if (!isset($settings['host']) || empty($settings['host'])) { $settings['host'] = 'localhost'; } if (!isset($settings['port']) || empty($settings['port'])) { $settings['port'] = '25'; } $mail->Host = $settings['host']; $mail->Port = $settings['port']; // set the connection type if ($settings['conn'] == 'ssl') { $mail->SMTPSecure = "ssl"; } elseif ($settings['conn'] == 'tls') { $mail->SMTPSecure = "tls"; } // smtp-authentication if ($settings['auth'] && !empty($settings['username'])) { $mail->SMTPAuth = true; $mail->Username = $settings['username']; $mail->Password = $settings['password']; } $mail->Body = $message; $mail->Subject = $subject; // add the newly created message-id // in phpmailer as a public var $mail->MessageID = $data['messageid']; // add custom headers if defined if (!empty($data['custom_headers'])) { // custom headers in phpmailer are added one by one $custom_headers = explode("\n", $data['custom_headers']); foreach ($custom_headers as $cheader) { $mail->AddCustomHeader($cheader); } } // add attachments if provided if (isset($data['attachments']) && count($data['attachments'])) { /* * Expected input is an array of * * array( * 'filename'=>'name of the file including extension', * 'filedata'=>'plain (not encoded) content of the file', * 'mimetype'=>'mime type of the file', (optional) * ) * */ foreach ($data['attachments'] as $att_id => $attachment) { $att_type = !empty($attachment['mimetype']) ? $attachment['mimetype'] : 'application/octet-stream'; $mail->AddStringAttachment($attachment['filedata'], $attachment['filename'], 'base64', $att_type); // try to unset it in the original array to save memory unset($data['attachments'][$att_id]); } } if (!empty($settings['bcc']) && $num_addresses > 3) { $bcc = 1; $mail->AddAddress("undisclosed-recipients:;"); } else { $bcc = 0; // lets keep the connection alive - it could be multiple mails $mail->SMTPKeepAlive = true; } foreach ($addresses as $address) { if ($bcc) { $mail->addBCC($address); } else { $mail->AddAddress($address); if (!$mail->Send()) { $error_msg = "There was an error sending the message."; $detail_msg = "Error returned was: " . $mail->ErrorInfo; if (function_exists('event_logging_writelog')) { event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE)); } if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) { echo $error_msg . "\n"; echo $detail_msg; } } elseif (!empty($settings['log_successful'])) { if (function_exists('event_logging_writelog')) { event_logging_writelog(array("source" => "smtp_mail", "message" => "Email successfully sent", "details" => "An email has been sent:\nTo:{$address}\nSubject: {$subject}\nBody: {$message}\n", "loglevel" => EVENTLOG_LVL_INFO, "category" => EVENTLOG_CAT_MODULE)); } } // Clear all addresses for next loop $mail->ClearAddresses(); } } // bcc needs just one send call if ($bcc) { if (!$mail->Send()) { $error_msg = "There was an error sending the bcc message."; $detail_msg = "Error returned was: " . $mail->ErrorInfo; if (function_exists('event_logging_writelog')) { event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE)); } if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) { echo $error_msg . "\n"; echo $detail_msg; } } elseif (!empty($settings['log_successful'])) { if (function_exists('event_logging_writelog')) { $address_join = implode(",", $addresses); event_logging_writelog(array("source" => "smtp_mail", "message" => "BCC-Email successfully sent", "details" => "An email (bcc-mode) has been sent:\nBCC:{$address_join}\nSubject: {$subject}\nBody: {$message}\n", "loglevel" => EVENTLOG_LVL_INFO, "category" => EVENTLOG_CAT_MODULE)); } } } // we have to close the connection with pipelining // which is only used in non-bcc mode if (!$bcc) { $mail->SmtpClose(); } } catch (Exception $e) { $error_msg = "There was a problem communicating with SMTP"; $detail_msg = "The error returned was: " . $e->getMessage(); if (function_exists('event_logging_writelog')) { event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE)); } if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) { echo $error_msg . "\n"; echo $detail_msg; } exit; } } unset($message); unset($mail); // make sure that the internal mail-facility doesn't kick in return 0; }
/** * Function to mail the content * @param string $content * @param string $subject * @param string $email (from email) * @param string $realname (from name) * @param string/array $recipient (to) * @return void */ function mail_it($content, $subject, $email, $realname, $recipient, $inbound = true) { global $attachment_chunk, $attachment_name, $attachment_type, $attachment_temp; global $local_chunk, $local_name, $local_type, $local_temp; global $bcc, $cc; global $PHPMailerLocation, $PHPMailerLiteLocation; global $fixedFromEmail, $fixedFromName, $text_only, $htmlCharset; global $addToCSV; $valSent = false; if ($realname) { $sendTo = $realname . "<" . $email . ">"; } else { $sendTo = $email; } $ob = "----=_OuterBoundary_000"; $ib = "----=_InnerBoundery_001"; $mail_headers = "MIME-Version: 1.0\r\n"; if ($fixedFromEmail != '') { $mail_headers .= "From: " . $fixedFromEmail . "\n"; } else { $mail_headers .= "From: " . $sendTo . "\n"; } $mail_headers .= "To: " . $recipient . "\n"; $mail_headers .= "Reply-To: " . $sendTo . "\n"; if ($cc) { $mail_headers .= "Cc: " . $cc . "\n"; } if ($bcc) { $mail_headers .= "Bcc: " . $bcc . "\n"; } $mail_headers .= "X-Priority: 1\n"; $mail_headers .= "X-Mailer: PHPMailer-FE v" . VERSION . " (software by worxware.com)\n"; $mail_headers .= "Content-Type: multipart/mixed;\n\tboundary=\"" . $ob . "\"\n"; $mail_message = "This is a multi-part message in MIME format.\n"; $mail_message .= "\n--" . $ob . "\n"; $mail_message .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $ib . "\"\n\n"; $mail_message .= "\n--" . $ib . "\n"; $mail_message .= "Content-Type: text/plain;\n\tcharset=\"" . $htmlCharset . "\"\n"; $mail_message .= "Content-Transfer-Encoding: quoted-printable\n\n"; $mail_message .= $content["text"] . "\n\n"; $mail_message .= "\n--" . $ib . "--\n"; if ($attachment_name && $inbound) { reset($attachment_name); reset($attachment_temp); //loop through the arrays to get the attached file names and attach each one. while ((list($key1, $val1) = each($attachment_name)) && (list($key2, $val2) = each($attachment_temp)) && (list($key3, $val3) = each($attachment_type)) && (list($key4, $val4) = each($attachment_chunk))) { $mail_message .= "\n--" . $ob . "\n"; $mail_message .= "Content-Type: {$val3};\n\tname=\"" . $val1 . "\"\n"; $mail_message .= "Content-Transfer-Encoding: base64\n"; $mail_message .= "Content-Disposition: attachment;\n\tfilename=\"" . $val1 . "\"\n\n"; $mail_message .= $val4; $mail_message .= "\n\n"; } } else { if ($local_name && $inbound === false) { $mail_message .= "\n--" . $ob . "\n"; $mail_message .= "Content-Type: {$local_type};\n\tname=\"" . $local_name . "\"\n"; $mail_message .= "Content-Transfer-Encoding: base64\n"; $mail_message .= "Content-Disposition: attachment;\n\tfilename=\"" . $local_name . "\"\n\n"; $mail_message .= $local_chunk; $mail_message .= "\n\n"; } } $mail_message .= "\n--" . $ob . "--\n"; if ((class_exists('PHPMailerLite') || class_exists('PHPMailer') || file_exists($PHPMailerLocation) || file_exists($PHPMailerLiteLocation)) && $_POST['text_only'] !== true) { if (!class_exists('PHPMailerLite') && file_exists($PHPMailerLiteLocation)) { require_once $PHPMailerLiteLocation; $mail = new PHPMailerLite(); } elseif (!class_exists('PHPMailer') && file_exists($PHPMailerLocation)) { require_once $PHPMailerLocation; $mail = new PHPMailer(); } if (isset($_POST['Mailer']) && strtolower(trim($_POST['Mailer'])) == "smtp") { $mail->IsSMTP(); if (isset($_POST['Host']) && trim($_POST['Host']) != "") { $mail->Host = trim($_POST['Host']); } if (isset($_POST['Port']) && trim($_POST['Port']) != "") { $mail->Port = trim($_POST['Port']); } if (isset($_POST['SMTPAuth']) && ($_POST['SMTPAuth'] === true || $_POST['SMTPAuth'] === false)) { $mail->SMTPAuth = $_POST['SMTPAuth']; } if (isset($_POST['Username']) && trim($_POST['Username']) != "") { $mail->Username = trim($_POST['Username']); } if (isset($_POST['Username']) && trim($_POST['Username']) != "") { $mail->Password = trim($_POST['Password']); } if (isset($_POST['Timeout']) && trim($_POST['Timeout']) != "") { $mail->Timeout = trim($_POST['Timeout']); } } elseif (isset($_POST['Mailer']) && strtolower(trim($_POST['Mailer'])) == "sendmail") { $mail->IsSendmail(); } elseif (isset($_POST['Mailer']) && strtolower(trim($_POST['Mailer'])) == "qmail") { $mail->IsQmail(); } if (isset($_POST['fixedFromEmail'])) { if (isset($_POST['fixedFromName']) && trim($_POST['fixedFromName']) == '') { $_POST['fixedFromName'] = $_POST['fixedFromEmail']; } if (stristr($mail->Version, '5.1')) { $mail->SetFrom($_POST['fixedFromEmail'], $_POST['fixedFromName']); } elseif (stristr($mail->Version, '5')) { $mail->SetFrom($_POST['fixedFromEmail'], $_POST['fixedFromName']); $mail->AddReplyTo($_POST['fixedFromEmail'], $_POST['fixedFromName']); } else { $mail->SetFrom($_POST['fixedFromEmail'], $_POST['fixedFromName']); } } else { if (!isset($realname) && trim($realname) == '') { $realname = $email; } if (stristr($mail->Version, '5.1')) { $mail->SetFrom($email, $realname); } elseif ($mail->Version >= 5) { $mail->SetFrom($email, $realname); $mail->AddReplyTo($email, $realname); } else { $mail->From = $email; $mail->FromName = $realname; } } $mail->Subject = $subject; $mail->AddAddress($recipient); if ($bcc) { if (strpos($bcc, ",") || strpos($bcc, ";")) { $bcc_in = explode(',', $bcc); foreach ($bcc_in as $key => $value) { $mail->AddBcc($value); } } else { $mail->AddBcc($bcc); } } if ($cc) { if (strpos($cc, ",") || strpos($cc, ";")) { $cc_in = explode(',', $cc); foreach ($cc_in as $key => $value) { $mail->AddCc($value); } } else { $mail->AddCc($cc); } } $mail->MsgHTML($content["html"]); $mail->AltBody = _html2txt($content['html']); if ($attachment_name && $inbound) { //Add attachment function is in phpmailer //reset the arrays to the top reset($attachment_name); reset($attachment_temp); //loop through the arrays to get the attached file names and attach each one. while ((list($key1, $val1) = each($attachment_name)) && (list($key2, $val2) = each($attachment_temp))) { $atchmnt = file_get_contents($val2); $mail->AddStringAttachment($atchmnt, $val1); } } else { if ($local_name && $inbound === false) { $mail->AddAttachment($local_temp, $local_name); } } if ($mail->Send()) { echo '<script type="text/javascript">document.getElementById("feprocessing").src="_src/complete.gif";</script>'; $valSent = true; } } else { if (@mail($recipient, $subject, $mail_message, $mail_headers)) { echo '<script type="text/javascript">document.getElementById("feprocessing").src="_src/complete.gif";</script>'; $valSent = true; } } if ($addToCSV) { $writeVal = _writeLine($subject, $content['csv']); } if ($valSent) { return true; } }
function sendMessage($messageToSend, $smtpServer, $attachedFiles = []) { $mail = new PHPMailer(); $mail->SMTPDebug = 3; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $smtpServer['smtp_host']; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead $mail->Username = $smtpServer['username']; // SMTP username $mail->Password = $smtpServer['password']; // SMTP password $mail->SMTPSecure = $smtpServer['secutiry']; // Enable TLS encryption, `ssl` also accepted $mail->Port = $smtpServer['smtp_post']; // TCP port to connect to $mail->setFrom($messageToSend['from_mail'], $messageToSend['from_name']); $emailsList = explode(',', $messageToSend['email']); foreach ($emailsList as $email) { $mail->addAddress(trim($email)); // Add a recipient } $mail->addReplyTo($messageToSend['reply_to'], $messageToSend['from_name']); if ($attachedFiles) { foreach ($attachedFiles as $attachedFile) { $mail->AddStringAttachment($attachedFile['content'], $attachedFile['name'], 'base64', $attachedFile['type']); } } $mail->isHTML(true); // Set email format to HTML $mail->CharSet = $messageToSend['charset']; $mail->Subject = $messageToSend['subject']; $mail->Body = $messageToSend['body']; if (!$mail->send()) { return $mail->ErrorInfo; } else { return true; } }
function Mail_part($sub, $emailbody, $finaltable, $reportfilename) { global $con; try { $select_to = mysqli_query($con, "SELECT * FROM LMC_USER_LOGIN_DETAILS WHERE RC_ID=2"); if ($row = mysqli_fetch_array($select_to)) { $toaddress = $row["ULD_EMAIL_ID"]; } $select_cc = mysqli_query($con, "SELECT * FROM LMC_USER_RIGHTS_CONFIGURATION WHERE URC_ID=10"); if ($row = mysqli_fetch_array($select_cc)) { $ccaddress = $row["URC_DATA"]; } $select_host = mysqli_query($con, "SELECT * FROM LMC_USER_RIGHTS_CONFIGURATION WHERE URC_ID=14"); if ($row = mysqli_fetch_array($select_host)) { $host = $row["URC_DATA"]; } $select_username = mysqli_query($con, "SELECT * FROM LMC_USER_RIGHTS_CONFIGURATION WHERE URC_ID=11"); if ($row = mysqli_fetch_array($select_username)) { $username = $row["URC_DATA"]; } $select_password = mysqli_query($con, "SELECT * FROM LMC_USER_RIGHTS_CONFIGURATION WHERE URC_ID=12"); if ($row = mysqli_fetch_array($select_password)) { $password = $row["URC_DATA"]; } $select_smtpsecure = mysqli_query($con, "SELECT * FROM LMC_USER_RIGHTS_CONFIGURATION WHERE URC_ID=13"); if ($row = mysqli_fetch_array($select_smtpsecure)) { $smtpsecure = $row["URC_DATA"]; } $admin_name = substr($ccaddress, 0, strpos($ccaddress, '@')); $sadmin_name = substr($toaddress, 0, strpos($toaddress, '@')); if (substr($admin_name, 0, strpos($admin_name, '.'))) { $admin_name = strtoupper(substr($admin_name, 0, strpos($admin_name, '.'))); } else { $admin_name = $admin_name; } if (substr($sadmin_name, 0, strpos($sadmin_name, '.'))) { $sadmin_name = strtoupper(substr($sadmin_name, 0, strpos($sadmin_name, '.'))); } else { $sadmin_name = $sadmin_name; } $spladminname = $admin_name . '/' . $sadmin_name; $spladminname = strtoupper($spladminname); $emailbody = str_replace('[SADMIN]', $spladminname, $emailbody); $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = $host; $mail->SMTPAuth = true; $mail->Username = $username; $mail->Password = $password; $mail->SMTPSecure = $smtpsecure; $mail->Port = 587; $mail->FromName = 'LMC'; $mail->addAddress($toaddress); $mail->addCC($ccaddress); $mail->WordWrap = 50; $mail->isHTML(true); $mail->Subject = $sub; $mail->Body = $emailbody; // pdf attachment $mpdf = new mPDF('utf-8', 'A4'); $mpdf->debug = true; $mpdf->SetHTMLFooter('<div style="text-align: center;">{PAGENO}</div>'); $mpdf->WriteHTML($finaltable); $reportpdf = $mpdf->Output('foo.pdf', 'S'); $mail->AddStringAttachment($reportpdf, $reportfilename . '.pdf'); $mail->send(); } catch (Exception $ex) { return $ex->getMessage(); } }
$mail->IsMail(); break; } $mail->Sender = $_SESSION['GO_SESSION']["email"]; $mail->From = $_SESSION['GO_SESSION']["email"]; // $mail->FromName = $name; $mail->FromName = $_SESSION['GO_SESSION']["name"]; $mail->AddReplyTo($_SESSION['GO_SESSION']["email"], $_SESSION['GO_SESSION']["name"]); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = sprintf($subjectEventInvitation, $name); require_once $GO_MODULES->class_path . 'go_ical.class.inc'; $ical = new go_ical(); $ics_string = $ical->export_event($event_id); if ($ics_string) { $mail->AddStringAttachment($ics_string, $name . '.ics', 'base64', 'text/calendar'); } for ($i = 0; $i < sizeof($participants); $i++) { $id = 0; if ($ab_module) { $user_profile = $ab->get_contact_profile_by_email(smart_addslashes($participants[$i]), $GO_SECURITY->user_id); $id = $user_profile["source_id"]; } else { $user_profile = false; } if (!$user_profile) { $user_profile = $GO_USERS->get_profile_by_email(smart_addslashes($participants[$i])); $id = $user_profile["id"]; } if ($user_profile) { $middle_name = $user_profile['middle_name'] == '' ? '' : $user_profile['middle_name'] . ' ';
function sendMail($admin_data, $user, $content, $partner) { global $gTables; global $email_enabled; global $email_disclaimer; require_once "../../library/phpmailer/class.phpmailer.php"; require_once "../../library/phpmailer/class.smtp.php"; // // Se è possibile usare la posta elettronica, si procede. // if (!$email_enabled) { echo "invio e-mail <b style=\"color: #ff0000;\">disabilitato... ERROR!</b><br />mail send is <b style=\"color: #ff0000;\">disabled... ERROR!</b> "; return; } // // Si procede con la costruzione del messaggio. // // definisco il server SMTP e il mittente $config_mailer = gaz_dbi_get_row($gTables['company_config'], 'var', 'mailer'); $config_host = gaz_dbi_get_row($gTables['company_config'], 'var', 'smtp_server'); $config_notif = gaz_dbi_get_row($gTables['company_config'], 'var', 'return_notification'); $config_port = gaz_dbi_get_row($gTables['company_config'], 'var', 'smtp_port'); $config_secure = gaz_dbi_get_row($gTables['company_config'], 'var', 'smtp_secure'); $config_user = gaz_dbi_get_row($gTables['company_config'], 'var', 'smtp_user'); $config_pass = gaz_dbi_get_row($gTables['company_config'], 'var', 'smtp_password'); // se non è possibile usare ini_set allora la mail verrà trasmessa usando i // dati attinti su php.ini $body_text = gaz_dbi_get_row($gTables['body_text'], 'table_name_ref', 'body_send_doc_email'); $mailto = $partner['e_mail']; //recipient $subject = $admin_data['ragso1'] . " " . $admin_data['ragso2'] . "-Trasmissione documenti"; //subject $email_disclaimer = "" . $email_disclaimer != "" ? "<p>" . $email_disclaimer . "</p>" : ""; // Costruisco il testo HTML dell'email $body_text['body_text'] .= "<h3><span style=\"color: #000000; background-color: #" . $admin_data['colore'] . ";\">Company: " . $admin_data['ragso1'] . " " . $admin_data['ragso2'] . "</span></h3>"; $admin_data['web_url'] = trim($admin_data['web_url']); $body_text['body_text'] .= empty($admin_data['web_url']) ? "" : "<h4><span style=\"color: #000000;\">Web: <a href=\"" . $admin_data['web_url'] . "\">" . $admin_data['web_url'] . "</a></span></h4>"; $body_text['body_text'] .= "<address><span style=\"color: #" . $admin_data['colore'] . ";\">User: "******" " . $user['Cognome'] . "</span><br /></address>"; $body_text['body_text'] .= "<hr />" . $email_disclaimer; // // Inizializzo PHPMailer // $mail = new PHPMailer(); $mail->Host = $config_host['val']; $mail->IsHTML(); // Modalita' HTML // Imposto il server SMTP if (!empty($config_port['val'])) { $mail->Port = $config_port['val']; // Imposto la porta del servizio SMTP } switch ($config_mailer['val']) { case "smtp": // Invio tramite protocollo SMTP $mail->SMTPDebug = 2; // Attivo il debug $mail->IsSMTP(); // Modalita' SMTP if (!empty($config_secure['val'])) { $mail->SMTPSecure = $config_secure['val']; // Invio tramite protocollo criptato } $mail->SMTPAuth = !empty($config_user['val']) && $config_mailer['val'] == 'smtp' ? TRUE : FALSE; if ($mail->SMTPAuth) { $mail->Username = $config_user['val']; // Imposto username per autenticazione SMTP $mail->Password = $config_pass['val']; // Imposto password per autenticazione SMTP } break; case "mail": default: break; } // Imposto eventuale richiesta di notifica if ($config_notif['val'] == 'yes') { $mail->AddCustomHeader($mail->HeaderLine("Disposition-notification-to", $admin_data['e_mail'])); } // Imposto email del mittente $mail->SetFrom($admin_data['e_mail'], $admin_data['ragso1'] . " " . $admin_data['ragso2']); // Imposto email del destinatario $mail->AddAddress($mailto); // Aggiungo l'email del mittente tra i destinatari in cc $mail->AddCC($admin_data['e_mail'], $admin_data['ragso1'] . " " . $admin_data['ragso2']); // Imposto l'oggetto dell'email $mail->Subject = $subject; // Imposto il testo HTML dell'email $mail->MsgHTML($body_text['body_text']); // Aggiungo la fattura in allegato $mail->AddStringAttachment($content->string, $content->name, $content->encoding, $content->mimeType); // Invio... if ($mail->Send()) { echo "invio e-mail riuscito... <strong>OK</strong><br />mail send has been successful... <strong>OK</strong>"; // or use booleans here } else { echo "<br />invio e-mail <strong style=\"color: #ff0000;\">NON riuscito... ERROR!</strong><br />mail send has<strong style=\"color: #ff0000;\"> NOT been successful... ERROR!</strong> "; echo "<br />mailer error: " . $mail->ErrorInfo; } }
function ew_SendEmail($sFrEmail, $sToEmail, $sCcEmail, $sBccEmail, $sSubject, $sMail, $sFormat, $sCharset, $sSmtpSecure = "", $arAttachments = array(), $arImages = array(), $arProperties = NULL) { global $Language, $gsEmailErrDesc; $res = FALSE; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = EW_SMTP_SERVER; $mail->SMTPAuth = EW_SMTP_SERVER_USERNAME != "" && EW_SMTP_SERVER_PASSWORD != ""; $mail->Username = EW_SMTP_SERVER_USERNAME; $mail->Password = EW_SMTP_SERVER_PASSWORD; $mail->Port = EW_SMTP_SERVER_PORT; if ($sSmtpSecure != "") { $mail->SMTPSecure = $sSmtpSecure; } if (preg_match('/^(.+)<([\\w.%+-]+@[\\w.-]+\\.[A-Z]{2,6})>$/i', trim($sFrEmail), $m)) { $mail->From = $m[2]; $mail->FromName = trim($m[1]); } else { $mail->From = $sFrEmail; $mail->FromName = $sFrEmail; } $mail->Subject = $sSubject; if (ew_SameText($sFormat, "html")) { $mail->IsHTML(TRUE); $mail->Body = $sMail; } else { $mail->IsHTML(FALSE); $mail->Body = @Html2Text\Html2Text::convert($sMail); } if ($sCharset != "" && strtolower($sCharset) != "iso-8859-1") { $mail->CharSet = $sCharset; } $sToEmail = str_replace(";", ",", $sToEmail); $arrTo = explode(",", $sToEmail); foreach ($arrTo as $sTo) { $mail->AddAddress(trim($sTo)); } if ($sCcEmail != "") { $sCcEmail = str_replace(";", ",", $sCcEmail); $arrCc = explode(",", $sCcEmail); foreach ($arrCc as $sCc) { $mail->AddCC(trim($sCc)); } } if ($sBccEmail != "") { $sBccEmail = str_replace(";", ",", $sBccEmail); $arrBcc = explode(",", $sBccEmail); foreach ($arrBcc as $sBcc) { $mail->AddBCC(trim($sBcc)); } } if (is_array($arAttachments)) { foreach ($arAttachments as $attachment) { $filename = @$attachment["filename"]; $content = @$attachment["content"]; if ($content != "" && $filename != "") { $mail->AddStringAttachment($content, $filename); } else { if ($filename != "") { $mail->AddAttachment($filename); } } } } if (is_array($arImages)) { foreach ($arImages as $tmpimage) { $file = ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH) . $tmpimage; $cid = ew_TmpImageLnk($tmpimage, "cid"); $mail->AddEmbeddedImage($file, $cid, $tmpimage); } } if (is_array($arProperties)) { foreach ($arProperties as $key => $value) { $mail->set($key, $value); } } $res = $mail->Send(); $gsEmailErrDesc = $mail->ErrorInfo; // Uncomment to debug // var_dump($mail); exit(); return $res; }
public function add_pdf_attachement($string, $filename) { $this->mail->AddStringAttachment($string, $filename, 'base64', 'application/pdf'); }
$mail->Username = "******"; // SMTP account username $mail->Password = "******"; // SMTP account password $mail->SetFrom('*****@*****.**', 'List manager'); $mail->AddReplyTo('*****@*****.**', 'List manager'); $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; @MYSQL_CONNECT("localhost", "root", "password"); @mysql_select_db("my_company"); $query = "SELECT full_name, email, photo FROM employee WHERE id={$id}"; $result = @MYSQL_QUERY($query); while ($row = mysql_fetch_array($result)) { $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($row["email"], $row["full_name"]); $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg"); if (!$mail->Send()) { echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '<br />'; } else { echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')<br />'; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); } ?> </body> </html>
function ewrpt_SendEmail($sFrEmail, $sToEmail, $sCcEmail, $sBccEmail, $sSubject, $sMail, $sAttachmentFileName, $sAttachmentContent, $sFormat, $sCharset) { global $ReportLanguage, $gsEmailErrDesc; $res = FALSE; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = EWRPT_SMTP_SERVER; $mail->SMTPAuth = EWRPT_SMTP_SERVER_USERNAME != "" && EWRPT_SMTP_SERVER_PASSWORD != ""; $mail->Username = EWRPT_SMTP_SERVER_USERNAME; $mail->Password = EWRPT_SMTP_SERVER_PASSWORD; $mail->Port = EWRPT_SMTP_SERVER_PORT; $mail->From = $sFrEmail; $mail->FromName = $sFrEmail; $mail->Subject = $sSubject; $mail->Body = $sMail; if ($sCharset != "" && strtolower($sCharset) != "iso-8859-1") { $mail->Charset = $sCharset; } $sToEmail = str_replace(";", ",", $sToEmail); $arrTo = explode(",", $sToEmail); foreach ($arrTo as $sTo) { $mail->AddAddress(trim($sTo)); } if ($sCcEmail != "") { $sCcEmail = str_replace(";", ",", $sCcEmail); $arrCc = explode(",", $sCcEmail); foreach ($arrCc as $sCc) { $mail->AddCC(trim($sCc)); } } if ($sBccEmail != "") { $sBccEmail = str_replace(";", ",", $sBccEmail); $arrBcc = explode(",", $sBccEmail); foreach ($arrBcc as $sBcc) { $mail->AddBCC(trim($sBcc)); } } if (strtolower($sFormat) == "html") { $mail->ContentType = "text/html"; } else { $mail->ContentType = "text/plain"; } if ($sAttachmentContent != "" && $sAttachmentFileName != "") { $mail->AddStringAttachment($sAttachmentContent, $sAttachmentFileName); } else { if ($sAttachmentFileName != "") { $mail->AddAttachment($sAttachmentFileName); } } $res = $mail->Send(); $gsEmailErrDesc = $mail->ErrorInfo; // Uncomment to debug // var_dump($mail); exit(); return $res; }
function handleSubmits() { $adminNeeded = false; if (empty($_POST)) { return $adminNeeded; } if (isset($_POST['ezt-english'])) { global $l10n; unset($l10n[$this->domain]); $this->adminMsg = "<div class='updated'><p><strong>Ok, in English for now." . " <input type='button' value='Switch Back' onClick='location.reload(true)'></strong></p> </div>"; return $adminNeeded; } $adminNeeded = true; if (isset($_POST['ezt-translate'])) { $_POST['eztran'] = 'eztran'; if (isset($_POST['ezt-createpo'])) { $this->getSessionVars(); if ($this->target != $_POST['ezt-createpo']) { $this->rmSessionVars(); $this->target = $_POST['ezt-createpo']; $this->setLang($this->target); } } return $adminNeeded; } if (!isset($_POST['eztran'])) { return $adminNeeded; } if (!check_admin_referer('ezTranSubmit', 'ezTranNonce')) { return $adminNeeded; } if (isset($_POST['ezt-clear'])) { $this->status = '<div class="updated">Reloaded the translations from PHP files and MO.</div> '; $_SESSION[$this->domain] = array(); $this->target = $_POST['ezt-target']; $this->setLang($this->target); return $adminNeeded; } if (!empty($_POST['ezt-mailPot'])) { if ($this->isEmbedded || $this->isPro) { $locale = $_POST['locale']; $file = "{$locale}.po"; $potArray = unserialize(gzinflate(base64_decode($_POST['potArray']))); if (!class_exists("phpmailer")) { require_once ABSPATH . 'wp-includes/class-phpmailer.php'; } $mail = new PHPMailer(); $mail->From = get_bloginfo('admin_email'); $mail->FromName = get_bloginfo('name'); if ($this->isEmbedded) { $author = "Manoj Thulasidas"; $authormail = '*****@*****.**'; } else { $author = $_POST['ezt-author']; $authormail = $_POST['ezt-authormail']; } $mail->AddAddress($authormail, $author); $mail->CharSet = get_bloginfo('charset'); $mail->Mailer = 'php'; $mail->SMTPAuth = false; $mail->Subject = $file; foreach ($potArray as $domain => $str) { $filePO = "{$locale}_{$domain}.po"; $mail->AddStringAttachment($str, $filePO); } $pos1 = strpos($str, "msgstr"); $pos2 = strpos($str, "msgid", $pos1); $head = substr($str, 0, $pos2); $mail->Body = $head; if ($mail->Send()) { $this->status = "<div class='updated'>Pot file: {$file} was sent.</div>"; } else { $this->error = "<div class='error'>Error: {$mail->ErrorInfo} Please save the pot file and <a href='mailto:{$authormail}'>contact {$author}</a></div>"; } } else { $this->status = '<div style="background-color:#cff;padding:5px;margin:5px;border:solid 1px;margin-top:10px;font-weight:bold;color:red">In the <a href="http://buy.thulasidas.com/easy-translator">Pro Version</a>, the Pot file would have been sent to the plugin author.<br />In this Lite version, please download the PO file (using the "Display & Save POT File" button above) and email it using your mail client.</div><br />'; } return $adminNeeded; } return $adminNeeded; }
$mail->AddAddress($to); $mail->CharSet = 'UTF-8'; $mail->SetFrom($email); $mail->Subject = "Screen Recorder (Feedback): {$subject}"; $mail->MsgHTML($message); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 0; $mail->SMTPAuth = true; $mail->SMTPSecure = "tls"; $mail->Host = "************"; $mail->Port = 25; $mail->Username = "******"; $mail->Password = "******"; if (!empty($report)) { $mail->AddStringAttachment($report, 'report.txt', 'base64', 'text/plain'); } $succeed = $mail->Send(); if ($succeed) { echo "Succeed"; exit; } else { $error = "Failed to submit feedback. An error is occured: " . $mail->ErrorInfo; } } } } } } } }