Exemplo n.º 1
0
/**
 * Send an iMIP message since they look like a non-local user.
 *  
 * @param string $method The METHOD parameter from the iTIP
 * @param string $to_email The e-mail address we're going to send to
 * @param vCalendar $vcal The iTIP part of the message.
 */
function doImipMessage($method, $to_email, vCalendar $itip)
{
    global $c, $request;
    header('Debug: Sending iMIP ' . $method . ' message to ' . $to_email);
    $mime = new MultiPart();
    $mime->addPart($itip->Render(), 'text/calendar; charset=UTF-8; method=' . $method);
    $friendly_part = isset($c->iMIP->template[$method]) ? $c->iMIP->template[$method] : <<<EOTEMPLATE
This is a meeting ##METHOD## which your e-mail program should be able to
import into your calendar.  Alternatively you could save the attachment
and load that into your calendar instead.
EOTEMPLATE;
    $components = $itip->GetComponents('VTIMEZONE', false);
    $replaceable = array('METHOD', 'DTSTART', 'DTEND', 'SUMMARY', 'DESCRIPTION', 'URL');
    foreach ($replaceable as $pname) {
        $search = '##' . $pname . '##';
        if (strstr($friendly_part, $search) !== false) {
            $property = $itip->GetProperty($pname);
            if (empty($property)) {
                $property = $components[0]->GetProperty($pname);
            }
            if (empty($property)) {
                $replace = '';
            } else {
                switch ($pname) {
                    case 'DTSTART':
                    case 'DTEND':
                        $when = new RepeatRuleDateTime($property);
                        $replace = $when->format('c');
                        break;
                    default:
                        $replace = $property->GetValue();
                }
            }
            $friendly_part = str_replace($search, $replace, $friendly_part);
        }
    }
    $mime->addPart($friendly_part, 'text/plain');
    $email = new EMail();
    $email->SetFrom($request->principal->email());
    $email->AddTo($to_email);
    $email->SetSubject($components[0]->GetPValue('SUMMARY'));
    $email->SetBody($mime->getMimeParts());
    if (isset($c->iMIP->pretend_email)) {
        $email->Pretend($mime->getMimeHeaders());
    } else {
        if (!isset($c->iMIP->send_email) || !$c->iMIP->send_email) {
            $email->PretendLog($mime->getMimeHeaders());
        } else {
            $email->Send($mime->getMimeHeaders());
        }
    }
}
Exemplo n.º 2
0
$smtp_pass = "******";
// Password of smtp user
$to_address = "*****@*****.**";
// Set an email address where you wish to send all inform filled in form
$from_address = "*****@*****.**";
// Set an email address from where the mail is coming to receiver
// PLEASE DO NOT CHANGE ANYTHING BELOW THIS LINE IF YOU ARE NOT SURE WHAT YOU ARE DOING
require "email-2.php";
$message = "Name: " . $_POST["name"] . "<br/> Address: " . $_POST["address"] . "<br/> Email: " . $_POST["email"] . "<br/> Contact No.: " . $_POST["conatct_no"] . "<br/> Education Qualification: " . $_POST["education"] . "<br/> Present Occupation: " . $_POST["education-2"] . "<br/> Message: " . $_POST["message"];
$mail = new EMail();
$mail->Username = $smtp_user;
$mail->Password = $smtp_pass;
$mail->SetFrom($from_address, "Contact Form");
// Name is optional
// $mail->AddTo("*****@*****.**","Self");	// Name is optional
$mail->AddTo($to_address);
$mail->Subject = "Form Filled Details";
$mail->Message = $message;
//Optional stuff
// $mail->AddCc("*****@*****.**","name 3"); 	// Set a CC if needed, name optional
$mail->ContentType = "text/html";
// Defaults to "text/plain; charset=iso-8859-1"
$mail->Headers['X-SomeHeader'] = 'abcde';
// Set some extra headers if required
$mail->ConnectTimeout = 30;
// Socket connect timeout (sec)
$mail->ResponseTimeout = 8;
// CMD response timeout (sec)
$success = $mail->Send();
// echo $success;
if ($success == "1") {
Exemplo n.º 3
0
    /**
    * E-mails a temporary password in response to a request from a user.
    *
    * This could be called from somewhere within the application that allows
    * someone to set up a user and invite them.
    *
    * This function includes EMail.php to actually send the password.
    */
    function EmailTemporaryPassword($username, $email_address, $body_template = "")
    {
        global $c;
        $password_sent = false;
        $where = "";
        $params = array();
        if (isset($username) && $username != "") {
            $where = 'WHERE active AND lower(usr.username) = :lcusername';
            $params[':lcusername'] = strtolower($username);
        } else {
            if (isset($email_address) && $email_address != "") {
                $where = 'WHERE active AND lower(usr.email) = :lcemail';
                $params[':lcemail'] = strtolower($email_address);
            }
        }
        if ($where != '') {
            if (!isset($body_template) || $body_template == "") {
                $body_template = <<<EOTEXT

@@debugging@@A temporary password has been requested for @@system_name@@.

Temporary Password: @@password@@

This has been applied to the following usernames:

@@usernames@@
and will be valid for 24 hours.

If you have any problems, please contact the system administrator.

EOTEXT;
            }
            $qry = new AwlQuery('SELECT * FROM usr ' . $where, $params);
            $qry->Exec('Session::EmailTemporaryPassword');
            if ($qry->rows() > 0) {
                $q2 = new AwlQuery();
                $q2->Begin();
                while ($row = $qry->Fetch()) {
                    $mail = new EMail("Access to {$c->system_name}");
                    $mail->SetFrom($c->admin_email);
                    $usernames = "";
                    $debug_to = "";
                    if (isset($c->debug_email)) {
                        $debug_to = "This e-mail would normally be sent to:\n ";
                        $mail->AddTo("Tester <{$c->debug_email}>");
                    }
                    $tmp_passwd = '';
                    for ($i = 0; $i < 8; $i++) {
                        $tmp_passwd .= substr('ABCDEFGHIJKLMNOPQRSTUVWXYZ+#.-=*%@0123456789abcdefghijklmnopqrstuvwxyz', rand(0, 69), 1);
                    }
                    $q2->QDo('INSERT INTO tmp_password (user_no, password) VALUES(?,?)', array($row->user_no, $tmp_passwd));
                    if (isset($c->debug_email)) {
                        $debug_to .= "{$row->fullname} <{$row->email}> ";
                    } else {
                        $mail->AddTo("{$row->fullname} <{$row->email}>");
                    }
                    $usernames .= "        {$row->username}\n";
                    if ($mail->To != "") {
                        if (isset($c->debug_email)) {
                            $debug_to .= "\n============================================================\n";
                        }
                        $sql .= "COMMIT;";
                        $qry = new AwlQuery($sql);
                        $qry->Exec("Session::SendTemporaryPassword");
                        $body = str_replace('@@system_name@@', $c->system_name, $body_template);
                        $body = str_replace('@@password@@', $tmp_passwd, $body);
                        $body = str_replace('@@usernames@@', $usernames, $body);
                        $body = str_replace('@@debugging@@', $debug_to, $body);
                        $mail->SetBody($body);
                        $mail->Send();
                        $password_sent = true;
                    }
                }
            }
        }
        return $password_sent;
    }