messenger::to PHP Method

to() public method

Sets an email address to send to
public to ( $address, $realname = '' )
    function to($address, $realname = '')
    {
        global $config;
        if (!trim($address)) {
            return;
        }
        $pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0;
        $this->addresses['to'][$pos]['email'] = trim($address);
        // If empty sendmail_path on windows, PHP changes the to line
        if (!$config['smtp_delivery'] && DIRECTORY_SEPARATOR == '\\') {
            $this->addresses['to'][$pos]['name'] = '';
        } else {
            $this->addresses['to'][$pos]['name'] = trim($realname);
        }
    }

Usage Example

Example #1
0
    public function ucp_register_user_row_after($event)
    {
        if ($this->config['require_activation'] != USER_ACTIVATION_ADMIN) {
            // Grab an array of user_id's with a_user permissions ... these users can activate a user
            $admin_ary = $this->auth->acl_get_list(false, 'a_user', false);
            $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array();
            // Also include founders
            $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
            if (sizeof($admin_ary)) {
                $where_sql .= ' OR ' . $this->db->sql_in_set('user_id', $admin_ary);
            }
            $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
				FROM ' . USERS_TABLE . ' ' . $where_sql;
            $result = $this->db->sql_query($sql);
            $data = array('username' => $this->request->variable('username', '', true), 'email' => strtolower($this->request->variable('email', '')), 'user_regdate' => time(), 'user_ip' => $this->user->ip, 'lang' => basename($this->request->variable('lang', $this->user->lang_name)));
            while ($row = $this->db->sql_fetchrow($result)) {
                if (!class_exists('messenger')) {
                    include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
                }
                $messenger = new \messenger(false);
                $server_url = generate_board_url();
                $messenger->template('@dmzx_notifyadmin/admin_notify_registered', $data['lang']);
                $messenger->to($row['user_email'], $row['username']);
                $messenger->im($row['user_jabber'], $row['username']);
                $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'USER_MAIL' => $data['email'], 'USER_REGDATE' => date($this->config['default_dateformat'], $data['user_regdate']), 'USER_IP' => $data['user_ip']));
                $messenger->send(NOTIFY_EMAIL);
            }
            $this->db->sql_freeresult($result);
        }
    }
All Usage Examples Of messenger::to