/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin vtiger_users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the vtiger_attachments */ function send_mail($module, $to_email, $from_name, $from_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '', $logo = '') { global $adb, $log; global $root_directory; global $HELPDESK_SUPPORT_EMAIL_ID, $HELPDESK_SUPPORT_NAME; $uploaddir = $root_directory . "/test/upload/"; $adb->println("To id => '" . $to_email . "'\nSubject ==>'" . $subject . "'\nContents ==> '" . $contents . "'"); //Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of vtiger_users vtiger_table) //$to_email = getUserEmailId('id',$assigned_user_id); //if module is HelpDesk then from_email will come based on support email id if ($from_email == '') { //if from email is not defined, then use the useremailid as the from address $from_email = getUserEmailId('user_name', $from_name); } //if the newly defined from email field is set, then use this email address as the from address //and use the username as the reply-to address $query = "select * from vtiger_systems where server_type=?"; $params = array('email'); $result = $adb->pquery($query, $params); $from_email_field = $adb->query_result($result, 0, 'from_email_field'); if (isUserInitiated()) { $replyToEmail = $from_email; } else { $replyToEmail = $from_email_field; } if (isset($from_email_field) && $from_email_field != '') { //setting from _email to the defined email address in the outgoing server configuration $from_email = $from_email_field; } if ($module != "Calendar") { $contents = addSignature($contents, $from_name); } $mail = new PHPMailer(); setMailerProperties($mail, $subject, $contents, $from_email, $from_name, trim($to_email, ","), $attachment, $emailid, $module, $logo); setCCAddress($mail, 'cc', $cc); setCCAddress($mail, 'bcc', $bcc); if (!empty($replyToEmail)) { $mail->AddReplyTo($replyToEmail); } $mail->ConfirmReadingTo = $mail->From; //MSL // vtmailscanner customization: If Support Reply to is defined use it. global $HELPDESK_SUPPORT_EMAIL_REPLY_ID; if ($HELPDESK_SUPPORT_EMAIL_REPLY_ID && $HELPDESK_SUPPORT_EMAIL_ID != $HELPDESK_SUPPORT_EMAIL_REPLY_ID) { $mail->AddReplyTo($HELPDESK_SUPPORT_EMAIL_REPLY_ID); } // END // Fix: Return immediately if Outgoing server not configured if (empty($mail->Host)) { return 0; } // END $mail_status = MailSend($mail); if ($mail_status != 1) { $mail_error = getMailError($mail, $mail_status, $mailto); } else { $mail_error = $mail_status; } return $mail_error; }
/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin vtiger_users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all vtiger_files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the vtiger_attachments */ function send_mail($module, $to_email, $from_name, $from_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '', $logo = '') { global $adb, $log; global $root_directory; global $HELPDESK_SUPPORT_EMAIL_ID, $HELPDESK_SUPPORT_NAME; $uploaddir = $root_directory . "/test/upload/"; $adb->println("To id => '" . $to_email . "'\nSubject ==>'" . $subject . "'\nContents ==> '" . $contents . "'"); //Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of vtiger_users vtiger_table) //$to_email = getUserEmailId('id',$assigned_user_id); //if module is HelpDesk then from_email will come based on support email id if ($from_email == '') { //$module != 'HelpDesk') $from_email = getUserEmailId('user_name', $from_name); } if ($module != "Calendar") { $contents = addSignature($contents, $from_name); } $mail = new PHPMailer(); setMailerProperties($mail, $subject, $contents, $from_email, $from_name, trim($to_email, ","), $attachment, $emailid, $module, $logo); setCCAddress($mail, 'cc', $cc); setCCAddress($mail, 'bcc', $bcc); // vtmailscanner customization: If Support Reply to is defined use it. global $HELPDESK_SUPPORT_EMAIL_REPLY_ID; if ($HELPDESK_SUPPORT_EMAIL_REPLY_ID && $HELPDESK_SUPPORT_EMAIL_ID != $HELPDESK_SUPPORT_EMAIL_REPLY_ID) { $mail->AddReplyTo($HELPDESK_SUPPORT_EMAIL_REPLY_ID); } // END // Fix: Return immediately if Outgoing server not configured if (empty($mail->Host)) { return 0; } // END $mail_status = MailSend($mail); if ($mail_status != 1) { $mail_error = getMailError($mail, $mail_status, $mailto); } else { $mail_error = $mail_status; } return $mail_error; }
/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the vtiger_attachments */ function send_mail($module, $to_email, $from_name, $from_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '', $logo = '', $replyto = '') { global $adb, $log, $root_directory, $HELPDESK_SUPPORT_EMAIL_ID, $HELPDESK_SUPPORT_NAME; $uploaddir = $root_directory . "/test/upload/"; $adb->println("To id => '" . $to_email . "'\nSubject ==>'" . $subject . "'\nContents ==> '" . $contents . "'"); $femail = ''; if (substr($from_email, 0, 8) == 'FROM:::>') { $femail = substr($from_email, 8); $from_email = ''; } if (empty($from_name) and !empty($from_email)) { $sql = "select user_name from vtiger_users where status='Active' and (email1=? or email2=? or secondaryemail=?)"; $result = $adb->pquery($sql, array($from_email, $from_email, $from_email)); if ($result and $adb->num_rows($result) > 0) { $from_name = $adb->query_result($result, 0, 0); } } //if module is HelpDesk then from_email will come based on support email id if ($from_email == '') { //if from email is not defined, then use the useremailid as the from address $from_email = getUserEmailId('user_name', $from_name); } if (empty($from_email)) { $from_email = $HELPDESK_SUPPORT_EMAIL_ID; } //if the newly defined from email field is set, then use this email address as the from address //and use the username as the reply-to address $query = "select * from vtiger_systems where server_type=?"; $params = array('email'); $result = $adb->pquery($query, $params); $from_email_field = $adb->query_result($result, 0, 'from_email_field'); if (empty($replyto)) { if (isUserInitiated()) { global $current_user; $reply_to_secondary = GlobalVariable::getVariable('Users_ReplyTo_SecondEmail', 0, $module, $current_user->id); if ($reply_to_secondary == 1) { $sql = "select secondaryemail from vtiger_users where id=?"; $result = $adb->pquery($sql, array($current_user->id)); $second_email = ''; if ($result and $adb->num_rows($result) > 0) { $second_email = $adb->query_result($result, 0, 'secondaryemail'); } } if (!empty($second_email)) { $replyToEmail = $second_email; } else { $replyToEmail = $from_email; } } else { $replyToEmail = $from_email_field; } } else { $replyToEmail = $replyto; } if (isset($from_email_field) && $from_email_field != '') { //setting from _email to the defined email address in the outgoing server configuration $from_email = $from_email_field; } if ($femail != '') { $from_email = $femail; } if ($module != "Calendar") { $contents = addSignature($contents, $from_name); } $mail = new PHPMailer(); setMailerProperties($mail, $subject, $contents, $from_email, $from_name, trim($to_email, ","), $attachment, $emailid, $module, $logo); setCCAddress($mail, 'cc', $cc); setCCAddress($mail, 'bcc', $bcc); if (!empty($replyToEmail)) { $mail->AddReplyTo($replyToEmail); } // vtmailscanner customization: If Support Reply to is defined use it. global $HELPDESK_SUPPORT_EMAIL_REPLY_ID; if ($HELPDESK_SUPPORT_EMAIL_REPLY_ID && $HELPDESK_SUPPORT_EMAIL_ID != $HELPDESK_SUPPORT_EMAIL_REPLY_ID) { $mail->AddReplyTo($HELPDESK_SUPPORT_EMAIL_REPLY_ID); } // END // Fix: Return immediately if Outgoing server not configured if (empty($mail->Host)) { return 0; } $mail_status = MailSend($mail); if ($mail_status != 1) { $mail_error = getMailError($mail, $mail_status, $mailto); } else { $mail_error = $mail_status; } return $mail_error; }
require_once 'include/utils/utils.php'; require_once 'include/utils/VtlibUtils.php'; require_once 'modules/Emails/class.phpmailer.php'; require_once 'modules/Emails/mail.php'; require_once 'modules/Vtiger/helpers/ShortURL.php'; global $adb; $adb = PearDatabase::getInstance(); if (isset($_REQUEST['user_name']) && isset($_REQUEST['emailId'])) { $username = vtlib_purify($_REQUEST['user_name']); $result = $adb->pquery('select email1 from vtiger_users where user_name= ? ', array($username)); if ($adb->num_rows($result) > 0) { $email = $adb->query_result($result, 0, 'email1'); } if (vtlib_purify($_REQUEST['emailId']) == $email) { $options = array('handler_path' => 'modules/Users/ForgotPassword.php', 'handler_class' => 'Users_ForgotPassword_Handler', 'handler_function' => 'changePassword', 'handler_data' => array('username' => $username, 'email' => $email)); $trackURL = Vtiger_ShortURL_Helper::generateURL($options); $contents = 'Hi ' . $username . ', <br> This email was sent to you as you submitted the request to change password for Vtiger CRM.<br> Please follow this link to reset your password. <br><br>' . $trackURL; $mail = new PHPMailer(); setMailerProperties($mail, 'Request : ForgotPassword - vtigercrm', $contents, '*****@*****.**', $username, $email); $status = MailSend($mail); if ($status === 1) { header('Location: index.php?modules=Users&view=Login&status=1'); } else { header('Location: index.php?modules=Users&view=Login&statusError=1'); } } else { header('Location: index.php?modules=Users&view=Login&fpError=1'); } }
/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin vtiger_users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all vtiger_files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the vtiger_attachments */ function send_mail($module, $to_email, $from_name, $from_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '', $logo = '', $useGivenFromEmailAddress = false, $attachmentSrc = array()) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $root_directory = vglobal('root_directory'); global $HELPDESK_SUPPORT_EMAIL_ID, $HELPDESK_SUPPORT_NAME; $uploaddir = $root_directory . "/cache/upload/"; $adb->println("To id => '" . $to_email . "'\nSubject ==>'" . $subject . "'\nContents ==> '" . $contents . "'"); //Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of vtiger_users vtiger_table) //$to_email = getUserEmailId('id',$assigned_user_id); //if module is HelpDesk then from_email will come based on support email id if ($from_email == '') { //if from email is not defined, then use the useremailid as the from address $from_email = getUserEmailId('user_name', $from_name); } //if the newly defined from email field is set, then use this email address as the from address //and use the username as the reply-to address $cachedFromEmail = VTCacheUtils::getOutgoingMailFromEmailAddress(); if ($cachedFromEmail === null) { $query = "select from_email_field from vtiger_systems where server_type=?"; $params = array('email'); $result = $adb->pquery($query, $params); $from_email_field = $adb->query_result($result, 0, 'from_email_field'); VTCacheUtils::setOutgoingMailFromEmailAddress($from_email_field); } if (isUserInitiated()) { $replyToEmail = $from_email; } else { $replyToEmail = $from_email_field; } if (isset($from_email_field) && $from_email_field != '' && !$useGivenFromEmailAddress) { //setting from _email to the defined email address in the outgoing server configuration $from_email = $from_email_field; } if ($module != "Calendar") { //$contents = addSignature($contents,$from_name); //TODO improved during the reconstruction Signature $mail = new PHPMailer(); } setMailerProperties($mail, $subject, $contents, $from_email, $from_name, trim($to_email, ","), $attachment, $emailid, $module, $logo); setCCAddress($mail, 'cc', $cc); setCCAddress($mail, 'bcc', $bcc); if (!empty($replyToEmail)) { $mail->AddReplyTo($replyToEmail); } // vtmailscanner customization: If Support Reply to is defined use it. global $HELPDESK_SUPPORT_EMAIL_REPLY_ID; if ($HELPDESK_SUPPORT_EMAIL_REPLY_ID && $HELPDESK_SUPPORT_EMAIL_ID != $HELPDESK_SUPPORT_EMAIL_REPLY_ID) { $mail->AddReplyTo($HELPDESK_SUPPORT_EMAIL_REPLY_ID); } // END // Fix: Return immediately if Outgoing server not configured if (empty($mail->Host)) { return 0; } // END if (count($attachmentSrc)) { foreach ($attachmentSrc as $name => $src) { if (is_array($src)) { $mail->AddStringAttachment($src['string'], $src['filename'], $src['encoding'], $src['type']); } else { $mail->AddAttachment($src, $name); } } } $mail_status = MailSend($mail); if ($mail_status != 1) { $mail_error = getMailError($mail, $mail_status, $mailto); } else { $mail_error = $mail_status; } return $mail_error; }
if (vtlib_purify($_REQUEST['emailId']) == $email) { $time = time(); $options = array('handler_path' => 'modules/Users/handlers/ForgotPassword.php', 'handler_class' => 'Users_ForgotPassword_Handler', 'handler_function' => 'changePassword', 'handler_data' => array('username' => $username, 'email' => $email, 'time' => $time, 'hash' => md5($username . $time))); $trackURL = Vtiger_ShortURL_Helper::generateURL($options); $content = 'Dear Customer,<br><br> You recently requested a password reset for your VtigerCRM Open source Account.<br> To create a new password, click on the link <a target="_blank" href=' . $trackURL . '>here</a>. <br><br> This request was made on ' . date("Y-m-d H:i:s") . ' and will expire in next 24 hours.<br><br> Regards,<br> VtigerCRM Open source Support Team.<br>'; $mail = new PHPMailer(); $query = "select from_email_field,server_username from vtiger_systems where server_type=?"; $params = array('email'); $result = $adb->pquery($query, $params); $from = $adb->query_result($result, 0, 'from_email_field'); if ($from == '') { $from = $adb->query_result($result, 0, 'server_username'); } $subject = 'Request : ForgotPassword - vtigercrm'; setMailerProperties($mail, $subject, $content, $from, $username, $email); $status = MailSend($mail); if ($status === 1) { header('Location: index.php?modules=Users&view=Login&status=1'); } else { header('Location: index.php?modules=Users&view=Login&statusError=1'); } } else { header('Location: index.php?modules=Users&view=Login&fpError=1'); } }
$content = 'Уважамаемый Пользователь,<br><br> Вы запросили смену пароля в системе SalesPlatform Vtiger CRM.<br> Для создания нового пароля, нажмите на <a target="_blank" href=' . $trackURL . '>ссылку</a>. <br><br> Запрос был сделан ' . date("Y-m-d H:i:s") . ' и будет актуален следующее 24 часа.<br><br> С наилучшими пожеланиями,<br> Команда SalesPlatform.<br>'; $mail = new PHPMailer(); // $content = 'Dear Customer,<br><br> // You recently requested a password reset for your VtigerCRM Open source Account.<br> // To create a new password, click on the link <a target="_blank" href=' . $trackURL . '>here</a>. // <br><br> // This request was made on ' . date("Y-m-d H:i:s") . ' and will expire in next 24 hours.<br><br> // Regards,<br> // VtigerCRM Open source Support Team.<br>' ; // $mail = new PHPMailer(); // SalesPlatform.ru end // SalesPlatform.ru begin setMailerProperties($mail, 'Восстановление пароля', $content, null, $username, $email); //setMailerProperties($mail, 'Request : ForgotPassword - vtigercrm', $content, '*****@*****.**', $username, $email); // SalesPlatform.ru end $status = MailSend($mail); if ($status === 1) { header('Location: index.php?modules=Users&view=Login&status=1'); } else { header('Location: index.php?modules=Users&view=Login&statusError=1'); } } else { header('Location: index.php?modules=Users&view=Login&fpError=1'); } }
/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin vtiger_users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all vtiger_files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the vtiger_attachments */ function send_mail($module, $to_email, $from_name, $from_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '', $logo = '', $useGivenFromEmailAddress = false) { global $adb, $log; global $root_directory; global $HELPDESK_SUPPORT_EMAIL_ID, $HELPDESK_SUPPORT_NAME; global $WERPASCOPETESTUPLOAD; $uploaddir = $root_directory . "{$WERPASCOPETESTUPLOAD}/"; $adb->println("To id => '" . $to_email . "'\nSubject ==>'" . $subject . "'\nContents ==> '" . $contents . "'"); //Get the email id of assigned_to user -- pass the value and name, name must be "user_name" or "id"(field names of vtiger_users vtiger_table) //$to_email = getUserEmailId('id',$assigned_user_id); //if module is HelpDesk then from_email will come based on support email id if ($from_email == '') { //if from email is not defined, then use the useremailid as the from address $from_email = getUserEmailId('user_name', $from_name); } //if the newly defined from email field is set, then use this email address as the from address //and use the username as the reply-to address $cachedFromEmail = VTCacheUtils::getOutgoingMailFromEmailAddress(); if ($cachedFromEmail === null) { $query = "select from_email_field from vtiger_systems where server_type=?"; $params = array('email'); $result = $adb->pquery($query, $params); $from_email_field = $adb->query_result($result, 0, 'from_email_field'); VTCacheUtils::setOutgoingMailFromEmailAddress($from_email_field); } if (isUserInitiated()) { $replyToEmail = $from_email; } else { $replyToEmail = $from_email_field; } if (isset($from_email_field) && $from_email_field != '' && !$useGivenFromEmailAddress) { //setting from _email to the defined email address in the outgoing server configuration $from_email = $from_email_field; } if ($module != "Calendar") { $contents = addSignature($contents, $from_name); } $mail = new PHPMailer(); setMailerProperties($mail, $subject, $contents, $from_email, $from_name, trim($to_email, ","), $attachment, $emailid, $module, $logo); setCCAddress($mail, 'cc', $cc); setCCAddress($mail, 'bcc', $bcc); // SalesPlatform.ru begin // Duplicated AddReplyTo() call. First into the setMailerProperties() //if(!empty($replyToEmail)) { // $mail->AddReplyTo($replyToEmail); //} // SalesPlatform.ru end // vtmailscanner customization: If Support Reply to is defined use it. global $HELPDESK_SUPPORT_EMAIL_REPLY_ID; if ($HELPDESK_SUPPORT_EMAIL_REPLY_ID && $HELPDESK_SUPPORT_EMAIL_ID != $HELPDESK_SUPPORT_EMAIL_REPLY_ID) { $mail->AddReplyTo($HELPDESK_SUPPORT_EMAIL_REPLY_ID); } // END // Fix: Return immediately if Outgoing server not configured if (empty($mail->Host)) { return 0; } // END $mail_status = MailSend($mail); if ($mail_status != 1) { $mail_error = getMailError($mail, $mail_status, $mailto); } else { $mail_error = $mail_status; // SalesPlatform.ru begin corrected date of sending $query = 'UPDATE vtiger_emaildetails SET email_flag ="SENT" WHERE emailid=?'; $adb->pquery($query, array($emailid)); // SalesPlatform.ru end } return $mail_error; }