function sendMail(ezcMail $mail) { $sendMailSettings = eZINI::instance('ezsendmailsettings.ini'); $sendMailParameter = $sendMailSettings->variable('SendNewsletter', 'MTAEnvelopeReturnPathParameter'); $transport = new ezcMailMtaTransport(); $transport->send($mail); }
private function send_password($email, $password) { $mail = new ezcMailComposer(); $mail->from = new ezcMailAddress('*****@*****.**', 'Open Keidas'); $mail->addTo(new ezcMailAddress($email, '')); $mail->subject = 'Open Keidas -tunnuksesi'; $mail->plainText = "Hei,\n\nUusi Open Keidas-salasanasi on: {$password}\n\nVoit käyttää sitä kirjautuaksesi osoitteessa http://openkeidas.fi/mgd:login"; $mail->build(); $transport = new ezcMailMtaTransport(); $transport->send($mail); }
public static function onError(Exception $e = NULL) { echo JFExecutionHandler::BuildUserError($e); $mail = new ezcMailComposer(); $mail->from = new ezcMailAddress('*****@*****.**', 'JetFuel Error Mailer'); $mail->addTo(new ezcMailAddress('*****@*****.**', 'Blend Errors')); $mail->subject = "Error occured on " . $_SERVER['HTTP_HOST']; $mail->plainText = JFExecutionHandler::BuildPlainTextEmail($e); $mail->htmlText = JFExecutionHandler::BuildEmail($e); $mail->build(); $transport = new ezcMailMtaTransport(); $transport->send($mail); }
/** * Choose opportuneness send-logic * * @param object $ezcMailComposerObject * @return error message / boolean */ public function send(ezcMail $ezcMailComposerObject) { $iniTransport = $this->transportMethod; $cjwNewsletterINI = eZINI::instance('cjw_newsletter.ini'); switch ($iniTransport) { case 'smtp': // read smtp settings from ini $smtpTransportServer = $cjwNewsletterINI->variable('NewsletterMailSettings', 'SmtpTransportServer'); $smtpTransportPort = $cjwNewsletterINI->variable('NewsletterMailSettings', 'SmtpTransportPort'); $smtpTransportUser = $cjwNewsletterINI->variable('NewsletterMailSettings', 'SmtpTransportUser'); $smtpTransportPassword = $cjwNewsletterINI->variable('NewsletterMailSettings', 'SmtpTransportPassword'); $smtpTransportConnectionType = $cjwNewsletterINI->variable('NewsletterMailSettings', 'SmtpTransportConnectionType'); $options = new ezcMailSmtpTransportOptions(); if ($smtpTransportConnectionType) { $options->connectionType = $smtpTransportConnectionType; } $transport = new ezcMailSmtpTransport($smtpTransportServer, $smtpTransportUser, $smtpTransportPassword, $smtpTransportPort, $options); break; case 'file': // var/log/mail $mailDir = $cjwNewsletterINI->variable('NewsletterMailSettings', 'FileTransportMailDir'); $transport = new CjwNewsletterTransportFile($mailDir); break; case 'sendmail': case 'mta': $transport = new ezcMailMtaTransport(); break; } try { $transport->send($ezcMailComposerObject); // CjwNewsletterLog::writeInfo( 'email send ok', 'CjwNewsletterTransport', 'send' ); return true; } catch (ezcMailTransportException $e) { // error by transport with tracking eZDebug::writeError('CjwNewsletterTransport:send: ' . $e->getMessage()); return $e; } }
<?php $message = new ezcMailComposer(); $message->from = new ezcMailAddress('*****@*****.**'); $message->addTo(new ezcMailAddress('*****@*****.**', 'Adam')); $message->subject = 'New Version of PHP Released!'; $body = 'Go to http://www.php.net and download it today!'; $message->plainText = $body; $html = '<html><body><b>Hooray!</b> New PHP Version!</body></html>'; $message->htmlText = $html; $message->build(); $sender = new ezcMailMtaTransport(); $sender->send($message);
<?php require_once 'tutorial_autoload.php'; // Create a new mail composer object $mail = new ezcMailComposer(); // Specify the "from" mail address $mail->from = new ezcMailAddress('*****@*****.**', 'John Doe'); // Add one "to" mail address (multiple can be added) $mail->addTo(new ezcMailAddress('*****@*****.**', 'Cindy Doe')); // Specify the subject of the mail $mail->subject = "Example of an HTML email with attachments"; // Specify the plain text of the mail $mail->plainText = "Here is the text version of the mail. This is displayed if the client can not understand HTML"; // Specify the html text of the mail $mail->htmlText = "<html>Here is the HTML version of your mail with an image: <img src='file://path_to_image.jpg' /></html>"; // Add an attachment to the mail $mail->addAttachment('path_to_attachment.file'); // Build the mail object $mail->build(); // Create a new MTA transport object $transport = new ezcMailMtaTransport(); // Use the MTA transport to send the created mail object $transport->send($mail);
static function register(&$message) { $db = ezcDbInstance::get(); $ini = $GLOBALS['ini']; $maxLength = $ini->getSetting('TheWire', 'maxUsernameLength'); $user_id = substr(preg_replace('/[^a-z]/', '', $_POST['user_id']), 0, $maxLength); $fullname = ucwords(strtolower(preg_replace('/[^a-zæøå ]/ui', '', $_POST['fullname']))); $jabber = preg_replace('/[^a-z.@]/', '', $_POST['jabber_name']); // check if the user already exists. $q = $db->createSelectQuery(); $q->select('id')->from('user')->where($q->expr->eq('id', $q->bindValue($user_id))); $s = $q->prepare(); $s->execute(); $r = $s->fetchAll(); if (count($r) > 0) { $message = "A user with username '{$user_id}' already exists."; return false; } // generate password mt_srand(base_convert($user_id, 36, 10) * microtime(true)); $a = base_convert(mt_rand(), 10, 36); $b = base_convert(mt_rand(), 10, 36); $password = substr($b . $a, 1, 8); // create user $q = $db->createInsertQuery(); $q->insertInto('user')->set('id', $q->bindValue($user_id))->set('jabber', $q->bindValue($jabber))->set('fullname', $q->bindValue($fullname))->set('password', $q->bindValue(md5($password)))->set('timezone', $q->bindValue($_POST['timezone'])); $s = $q->prepare(); $s->execute(); // create user prefs $db = ezcDbInstance::get(); $q = $db->createInsertQuery(); $q->insertInto('user_pref')->set('user_id', $q->bindValue($user_id))->set('mail_type', $q->bindValue(0))->set('http_refresh', $q->bindValue(1))->set('jabber_type', $q->bindValue(1)); $s = $q->prepare(); $s->execute(); // fetch settings $ini = $GLOBALS['ini']; $fromAddress = $ini->getSetting('TheWire', 'mailFrom'); $mailDomain = $ini->getSetting('TheWire', 'mailDomain'); $jabberUser = $ini->getSetting('jabber', 'user'); $jabberDomain = $ini->getSetting('jabber', 'domain'); $url = $ini->getSetting('TheWire', 'installDomain'); // send registration mail $m = new ezcMailComposer(); $m->from = new ezcMailAddress($fromAddress, 'The Wire'); $m->addTo(new ezcMailAddress($user_id . '@' . $mailDomain, $fullname)); $m->subject = 'Registration for The Wire'; $m->plainText = <<<ENDT Hello! We've created a user account. Your password is: \t{$password} You can now login at http://{$url}. Please change your password to something you want it to be. In order to make jabber integration work, please follow the following procedure: - Add the user "{$jabberUser}@{$jabberDomain}" to your jabber account. - Send a message like "hello" to this new user. - The jabber user will now authenticate you and ask for your authorization as well. - Authorize the jabber user so that it can send messages to you. regards, The Wire. ENDT; $m->build(); $s = new ezcMailMtaTransport(); $s->send($m); $message = "A user account has been created, see your mail to find further instructions."; return true; }