function send_confirmation_email($email, $data) { $lost_confirm = $data['verification_number']; $lost_uname = $data['uname']; $_from = array(SYSTEM_EMAIL => SYSTEM_EMAIL_NAME); $_to = array("{$email}" => $data['uname']); $_subject = "NinjaWars Account Confirmation Info"; $_body = render_template('lostconfirm_email_body.tpl', array('lost_uname' => $lost_uname, 'lost_confirm' => $lost_confirm, 'account_id' => $data['account_id'])); $mail_obj = new Nmail($_to, $_subject, $_body, $_from); $mail_obj->setReplyTo(array(SUPPORT_EMAIL => SUPPORT_EMAIL_NAME)); return $mail_obj->send(); }
function send_confirmation_email($email, $data) { $lost_confirm = $data['verification_number']; $lost_uname = $data['uname']; $confirmed = $data['confirmed']; /*$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= 'Reply-To: '.SUPPORT_EMAIL."\r\n";*/ $_from = array(SYSTEM_EMAIL => SYSTEM_EMAIL_NAME); $_to = array("{$email}" => $data['uname']); $_subject = "NinjaWars Account Confirmation Info"; $_body = render_template('lostconfirm_email_body.tpl', array('lost_uname' => $lost_uname, 'lost_confirm' => $lost_confirm, 'account_id' => $data['account_id'])); $mail_obj = new Nmail($_to, $_subject, $_body, $_from); $mail_obj->setReplyTo(array(SUPPORT_EMAIL => SUPPORT_EMAIL_NAME)); if (DEBUG) { $mail_obj->dump = true; } $sent = false; $sent = $mail_obj->send(); return $sent; }
/** * Sends the mail out using the php mail() function. * * @return boolean whether the mail function accepted the inputs. */ public function send() { // Create the Transport if (!self::$transport instanceof Swift_Transport) { self::$transport = Swift_MailTransport::newInstance(); } $mailer = Swift_Mailer::newInstance(self::$transport); $this->message = Swift_Message::newInstance()->setSubject($this->subject)->setFrom($this->from)->setTo($this->to)->setBody($this->body)->addPart('<p>' . $this->body . '</p>', 'text/html'); if ($this->reply_to) { $this->message->setReplyTo($this->reply_to); $this->message->setSender($this->from); // Have to set sender when there's a different reply-to. } if (defined('DEBUG') && DEBUG) { error_log($this->message . PHP_EOL, 3, LOGS . "emails.log"); } // Send the message along. return (bool) $mailer->send($this->message); }
$lost_email = in('email'); $data = $sql->QueryRow("SELECT confirm,uname FROM players WHERE email = '{$lost_email}'"); $lost_confirm = $data[0]; $lost_uname = $data[1]; echo "Retriving Confirm Code: It will be sent to your email.<br>\n"; if ($lost_uname == "") { echo "There are no accounts with that email. Please <a href=\"signup.php\">sign up</a> for an account.<br>\n"; die; } echo "Confirmation code being sent for account: {$lost_uname} ...\n"; $_to = "{$lost_email}"; $_subject = "NinjaWars Confirmation Code"; $_body = render_template('lostconfirm_email_body.tpl', array('WEB_ROOT' => WEB_ROOT, 'SUPPORT_EMAIL' => SUPPORT_EMAIL, 'lost_uname' => $lost_uname, 'lost_confirm' => $lost_confirm)); $_from = "{$headers}"; // Php generated. $mail_obj = new Nmail($_to, $_subject, $_body, $_from); if (DEBUG) { $mail_obj->dump = true; } $sent = false; $sent = $mail_obj->send(); if ($sent) { echo "Confirmation code sent."; } else { echo "NinjaWars was unable to send to that email address, please try again later."; } ?> <hr> <a href="main.php">Return to Game</a> </p>
function send_signup_email($account_id, $signup_email, $signup_name, $confirm, $class_identity) { /*$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".SYSTEM_EMAIL_NAME." <".SYSTEM__EMAIL.">\r\n"; $headers .= "Reply-To: ".SUPPORT_EMAIL_NAME." <".SUPPORT_EMAIL.">\r\n";*/ // *** Sends out the confirmation email to the chosen email address. *** $class_display = class_display_name_from_identity($class_identity); $_to = array("{$signup_email}" => $signup_name); $_subject = 'NinjaWars Account Sign Up'; $_body = render_template('signup_email_body.tpl', array('send_name' => $signup_name, 'signup_email' => $signup_email, 'confirm' => $confirm, 'send_class' => $class_display, 'SUPPORT_EMAIL' => SUPPORT_EMAIL, 'account_id' => $account_id)); $_from = array(SYSTEM_EMAIL => SYSTEM_EMAIL_NAME); // *** Create message object. *** $message = new Nmail($_to, $_subject, $_body, $_from); // *** Set replyto address. *** $message->setReplyTo(array(SUPPORT_EMAIL => SUPPORT_EMAIL_NAME)); if (DEBUG) { $message->dump = true; } $sent = false; // By default, assume failure. $sent = $message->send(); return $sent; }
<?php // Test-suite bootstrap require_once realpath(__DIR__) . '/../resources.php'; require_once CORE . 'base.inc.php'; require_once ROOT . 'tests/TestAccountCreateAndDestroy.php'; require_once ROOT . 'tests/NWTest.php'; //use NinjaWars\tests\TestAccountCreateAndDestroy; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; Nmail::$transport = Swift_NullTransport::newInstance();
function send_signup_email($account_id, $signup_email, $signup_name, $confirm, $class_identity) { // *** Sends out the confirmation email to the chosen email address. *** $class_display = class_display_name_from_identity($class_identity); $_to = array("{$signup_email}" => $signup_name); $_subject = 'NinjaWars Account Sign Up'; $_body = render_template('signup_email_body.tpl', array('send_name' => $signup_name, 'signup_email' => $signup_email, 'confirm' => $confirm, 'send_class' => $class_display, 'SUPPORT_EMAIL' => SUPPORT_EMAIL, 'account_id' => $account_id)); $_from = array(SYSTEM_EMAIL => SYSTEM_EMAIL_NAME); // *** Create message object. *** $message = new Nmail($_to, $_subject, $_body, $_from); // *** Set replyto address. *** $message->setReplyTo(array(SUPPORT_EMAIL => SUPPORT_EMAIL_NAME)); return $message->send(); }
function create_player($send_name, $params = array()) { $sql = new DBAccess(); $send_email = $params['send_email']; $send_pass = $params['send_pass']; $send_class = $params['send_class']; $preconfirm = (int) $params['preconfirm']; $confirm = (int) $params['confirm']; $referred_by = $params['referred_by']; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: " . SYSTEM_MESSENGER_NAME . " <" . SYSTEM_MESSENGER_EMAIL . ">\r\n"; $headers .= "Reply-To: " . SUPPORT_EMAIL_FORMAL_NAME . " <" . SUPPORT_EMAIL . ">\r\n"; // Create the initial player row. $playerCreationQuery = "INSERT INTO players\n\t\t (uname, pname, health, strength, gold, messages, kills, turns, confirm, confirmed,\n\t\t email, class, level, status, member, days, ip, bounty, clan, clan_long_name, created_date)\n\t\t VALUES\n\t\t ('{$send_name}','{$send_pass}','150','5','100','','0','180','{$confirm}','{$preconfirm}',\n\t\t '{$send_email}','{$send_class}','1','1','0','0','','0','','', now())"; // *** Inserts the choices and defaults into the player table. Status defaults to stealthed. *** $sql->Insert($playerCreationQuery); // *** Sends out the confirmation email to the chosen email address. *** $_to = "{$send_email}"; $_subject = "NinjaWars Account Sign Up"; $_body = render_template('signup_email_body.tpl', array('send_name' => $send_name, 'confirm' => $confirm, 'send_class' => $send_class, 'WEB_ROOT' => WEB_ROOT, 'SUPPORT_EMAIL' => SUPPORT_EMAIL)); $_from = "{$headers}"; // *** Create message object. $message = new Nmail($_to, $_subject, $_body, $_from); if (DEBUG) { $message->dump = true; } $sent = false; // By default, assume failure. $sent = $message->send(); // TODO: Need an in-game error logging. return $sent; }