⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 send.php

📁 groupoffice
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * @copyright Intermesh 2003 * @author Merijn Schering <mschering@intermesh.nl> * @version $Revision: 1.158 $ $Date: 2006/04/10 13:21:20 $ * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */require_once("../../Group-Office.php");$GO_SECURITY->authenticate();$GO_MODULES->authenticate('email');require_once($GO_LANGUAGE->get_language_file('email'));require_once($GO_CONFIG->class_path."mail/phpmailer/class.phpmailer.php");require_once($GO_CONFIG->class_path."mail/phpmailer/class.smtp.php");require_once($GO_CONFIG->class_path."html2text.class.inc");require_once($GO_MODULES->class_path."email.class.inc");$email = new email();require_once($GO_CONFIG->class_path.'mail/RFC822.class.inc');$RFC822 = new RFC822();   //load personal settings$em_settings = $email->get_settings($GO_SECURITY->user_id);//Check for templates plugin$tp_plugin = $GO_MODULES->get_plugin('templates', 'addressbook');if ($tp_plugin){	require_once($tp_plugin['class_path'].'templates.class.inc');	$tp = new templates();}//check for the addressbook module$ab_module = isset($GO_MODULES->modules['addressbook']) ? $GO_MODULES->modules['addressbook'] : false;if (!$ab_module || !$ab_module['read_permission']){	$ab_module = false;}else{	require_once($ab_module['class_path'].'addressbook.class.inc');	$ab = new addressbook();}$mail_subject = isset($_REQUEST['mail_subject']) ? smart_stripslashes($_REQUEST['mail_subject']) : '';$mail_body = isset($_REQUEST['mail_body']) ? smart_stripslashes($_REQUEST['mail_body']) : '';$mail_from = isset($_REQUEST['mail_from']) ? $_REQUEST['mail_from'] : 0;$mail_to = isset($_REQUEST['mail_to']) ? smart_stripslashes($_REQUEST['mail_to']) : '';$mail_cc = isset($_REQUEST['mail_cc']) ? smart_stripslashes($_REQUEST['mail_cc']) : '';$mail_bcc = isset($_REQUEST['mail_bcc']) ? smart_stripslashes($_REQUEST['mail_bcc']) : '';$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : 0;$show_cc = ((isset($_POST['show_cc']) && $_POST['show_cc'] == 'true') || !empty($mail_cc)) ? 'true' : 'false';$show_bcc = ((isset($_POST['show_bcc']) && $_POST['show_bcc'] == 'true') || !empty($mail_bcc)) ? 'true' : 'false';$html_mail_head = '<html><head><meta http-equiv=Content-Type content="text/html;charset='.$charset.'"><meta content="Group-Office '.$GO_CONFIG->version.'" name="GENERATOR"></head><body>';$html_mail_foot = '</body></html>';if($_SERVER['REQUEST_METHOD'] == 'POST'){	$notification_check = isset($_POST['notification']) ? true : false;}else{	$notification_check = $em_settings['request_notification'];}$mailing_group_id = isset($_REQUEST['mailing_group_id']) ? $_REQUEST['mailing_group_id'] : 0;$htmleditor = new htmleditor('mail_body') ;if(!$wysiwyg = $htmleditor->IsCompatible()){	$content_type= 'text/PLAIN';}else{	$content_type= isset($_POST['content_type']) ? $_POST['content_type'] : $em_settings['send_format'];}$page_title = $ml_compose;$sendaction = isset($_REQUEST['sendaction']) ? $_REQUEST['sendaction'] : '';$attachments_size = 0;function add_unknown_reciepent($email, $name, $addressbook_id){	global $GO_SECURITY, $ab;	$name_arr = split_name($name);	if($name_arr['first'] == '' && $name_arr['last'] == '')	{		$name_arr['first'] = $email;	}	if (!$ab->get_contact_by_email(addslashes($email),$GO_SECURITY->user_id))	{		$contact['addressbook_id'] = $addressbook_id;		$contact['first_name'] = addslashes($name_arr['first']);		$contact['middle_name'] = addslashes($name_arr['middle']);		$contact['last_name'] = addslashes($name_arr['last']);		$contact['email'] = addslashes($email);				$ab->add_contact($contact);	}}if($sendaction == 'save_draft'){	$save_draft = true;	$sendaction ='send';}switch ($sendaction){	case 'send':		if (!isset($_POST['mail_from']))		{			$profile = $GO_USERS->get_user($GO_SECURITY->user_id);			$middle_name = $profile['middle_name'] == '' ? '' : $profile['middle_name'].' ';			$name = $profile['first_name'].' '.$middle_name.$profile['last_name'];		}else		{			$profile = $email->get_account($_POST['mail_from']);			$name = $profile["name"];		}		$mail = new PHPMailer();		$mail->CharSet=$charset;		$mail->PluginDir = $GO_CONFIG->class_path.'mail/phpmailer/';		$mail->SetLanguage($php_mailer_lang, $GO_CONFIG->class_path.'mail/phpmailer/language/');		switch($GO_CONFIG->mailer)		{			case 'smtp':				$mail->Host = $GO_CONFIG->smtp_server;				$mail->Port = $GO_CONFIG->smtp_port;				$mail->IsSMTP();					if(!empty($GO_CONFIG->smtp_username))				{					$mail->SMTPAuth=true;					$mail->Username=$GO_CONFIG->smtp_username;								$mail->Password = $GO_CONFIG->smtp_password;				}		  				break;						case 'qmail':				$mail->IsQmail();				break;						case 'sendmail':				$mail->IsSendmail();				break;			case 'mail':				$mail->IsMail();				break;		}		$mail->Priority = $_POST['priority'];		$mail->Sender     = $profile["email"];    		$mail->From     = $profile["email"];		$mail->FromName = $name;		$mail->AddReplyTo($profile["email"],$name);		$mail->WordWrap = 76;		//$mail->Encoding = "quoted-printable";		if (isset($_POST['notification']))		{			$mail->ConfirmReadingTo = $profile["email"];		}		$html_message = $content_type == 'text/HTML' ? true : false;		$mail->IsHTML($html_message);		$mail->Subject = smart_stripslashes(trim($mail_subject));		if (isset($_SESSION['url_replacements']))		{			while($url_replacement = array_shift($_SESSION['url_replacements']))			{				$mail_body=str_replace($url_replacement['url'], "cid:".$url_replacement['id'], $mail_body);			}			unset($_SESSION['url_replacements']);		}		// Getting the attachments		if (isset($_SESSION['attach_array']))		{			for ($i=0;$i<count($_SESSION['attach_array']);$i++)			{				// If the temporary file exists, attach it				$tmp_file = stripslashes($_SESSION['attach_array'][$i]->tmp_file);				if (file_exists($tmp_file))				{					if ($_SESSION['attach_array'][$i]->disposition == 'attachment' || strpos($mail_body, $_SESSION['attach_array'][$i]->content_id))					{						if ($_SESSION['attach_array'][$i]->disposition == 'attachment')						{							$mail->AddAttachment($tmp_file, $_SESSION['attach_array'][$i]->file_name, 'base64',  $_SESSION['attach_array'][$i]->file_mime) ;						}else						{							$mail->AddEmbeddedImage($tmp_file, $_SESSION['attach_array'][$i]->content_id, imap_8bit($_SESSION['attach_array'][$i]->file_name), 'base64',  $_SESSION['attach_array'][$i]->file_mime);						}					}				}			}		}		$mail_to_array = $RFC822->parse_address_list($mail_to);		foreach ($mail_to_array as $to_address)		{     				$mail->AddAddress($to_address['email'], $to_address['personal']);			if ($em_settings['add_recievers'] > 0 && $ab_module)			{				add_unknown_reciepent($to_address['email'], $to_address['personal'], $em_settings['add_recievers']);			}		}		$mail_cc_array = $RFC822->parse_address_list($mail_cc);		foreach ($mail_cc_array as $cc_address)		{			$mail->AddCC($cc_address['email'], $cc_address['personal']);			if ($em_settings['add_recievers'] > 1 && $ab_module)			{				add_unknown_reciepent($cc_address['email'], $cc_address['personal'], $em_settings['add_recievers']);			}		}		$mail_bcc_array = $RFC822->parse_address_list($mail_bcc);		foreach ($mail_bcc_array as $bcc_address)		{			$mail->AddBCC($bcc_address['email'], $bcc_address['personal']);			if ($em_settings['add_recievers'] > 1 && $ab_module)			{				add_unknown_reciepent($bcc_address['email'], $bcc_address['personal'], $em_settings['add_recievers']);			}		}				if(function_exists('iconv') && $em_settings['charset'] != $charset)		{			$mail->CharSet=$em_settings['charset'];		}		if ($html_message)		{			if($mail->CharSet!=$charset)			{				$html_mail_head = str_replace($charset, $mail->CharSet, $html_mail_head);			}						$mail->Body = $html_mail_head.$mail_body.$html_mail_foot;			$htmlToText = new Html2Text ($mail_body);			$mail->AltBody = $htmlToText->get_text();							}else		{			$mail->Body = $mail_body;		}				if($mail->CharSet!=$charset)		{			$mail->recode($charset);		}				if(isset($save_draft))		{			//set Line enidng to \r\n for Cyrus IMAP			$mail->LE = "\r\n";			$mime = $mail->GetMime();			require_once($GO_CONFIG->class_path."mail/imap.class.inc");			$imap_stream = new imap();			$account = $email->get_account($_REQUEST['mail_from']);			if ($imap_stream->open($account["host"], "imap", $account["port"], $account["username"], $account["password"], $account['drafts'], 0, $account['use_ssl'], $account['novalidate_cert']))			{				if ($imap_stream->append_message($account['drafts'], $mime,"\\Draft \\Seen"))				{					if (isset($_SESSION['attach_array']))					{						while($attachment = array_shift($_SESSION['attach_array']))						{							@unlink($attachment->tmp_file);						}					}					// We need to unregister the attachments array					unset($_SESSION['attach_array']);					$imap_stream->close();					require_once($GO_THEME->theme_path."header.inc");					echo "<script type=\"text/javascript\">\r\nwindow.close();\r\n</script>\r\n";					require_once($GO_THEME->theme_path."footer.inc");					exit();				}else				{					$feedback = '<p class="Error">'.$ml_save_draft_error.' '.$mail->ErrorInfo.'</p>';				}			}		}else		{			if(!$mail->Send())			{				$feedback = '<p class="Error">'.$ml_send_error.' '.$mail->ErrorInfo.'</p>';			}else			{				//set Line enidng to \r\n for Cyrus IMAP				$mail->LE = "\r\n";				$mime = $mail->GetMime();				if (isset($_SESSION['attach_array']))				{					while($attachment = array_shift($_SESSION['attach_array']))					{						@unlink($attachment->tmp_file);					}				}				// We need to unregister the attachments array				unset($_SESSION['attach_array']);				if ($profile["type"] == "imap")				{					$sent_folder = $profile['sent'];					if ($sent_folder != '')					{						require_once($GO_CONFIG->class_path."mail/imap.class.inc");						$imap_stream = new imap();						if (!empty($mime) && $imap_stream->open($profile["host"], "imap", $profile["port"], $profile["username"], $profile["password"], $sent_folder, 0, $profile['use_ssl'], $profile['novalidate_cert']))						{							if ($imap_stream->append_message($sent_folder, $mime,"\\Seen"))							{								if (isset($_REQUEST['action']))								{									if($_REQUEST['action']== "reply" || $_REQUEST['action'] == "reply_all")									{										$uid_arr = array($_REQUEST['uid']);										$imap_stream->set_message_flag($_POST['mailbox'], $uid_arr, "\\Answered");									}								}								$imap_stream->close();								require_once($GO_THEME->theme_path."header.inc");								echo "<script type=\"text/javascript\">\r\nwindow.close();\r\n</script>\r\n";								require_once($GO_THEME->theme_path."footer.inc");								exit();							}						}						require_once($GO_THEME->theme_path."header.inc");						echo "<script type=\"text/javascript\">\r\nalert('".$ml_sent_items_fail."');\r\nwindow.close();\r\n</script>\r\n";						require_once($GO_THEME->theme_path.'footer.inc');						exit();					}else					{						require_once($GO_THEME->theme_path."header.inc");						echo "<script type=\"text/javascript\">\r\nwindow.close();\r\n</script>\r\n";						require_once($GO_THEME->theme_path.'footer.inc');						exit();					}				}else				{					require_once($GO_THEME->theme_path.'header.inc');					echo "<script type=\"text/javascript\">\r\nwindow.close();\r\n</script>\r\n";					require_once($GO_THEME->theme_path.'footer.inc');					exit();				}			}		}		break;}//if a template id is given then process it$template_id = isset($_REQUEST['template_id']) ? $_REQUEST['template_id'] : 0;$contact_id = isset($_REQUEST['contact_id']) ? $_REQUEST['contact_id'] : 0;$company_id = isset($_REQUEST['company_id']) ? $_REQUEST['company_id'] : 0;if($mailing_group_id > 0 && $tp->get_contacts_from_mailing_group($mailing_group_id) == 0 && $tp->get_companies_from_mailing_group($mailing_group_id) == 0 && $tp->get_users_from_mailing_group($mailing_group_id) == 0){	require_once($GO_THEME->theme_path."header.inc");	$tabtable = new tabstrip('templates_tabstrip', $ml_attention);	$tabstrip->set_attribute('style','width:100%');	$tabstrip->add_html_element(new html_element('p', $ml_no_contacts_in_mailing_group));	$tabstrip->add_html_element(new button($cmdClose, "javascript:window.close();"));	echo $tabstrip->get_html();	require_once($GO_THEME->theme_path."footer.inc");	exit();}if ($tp_plugin){	$template_count = $tp->get_authorized_templates($GO_SECURITY->user_id, EMAIL_TEMPLATE);}$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';if ($_SERVER['REQUEST_METHOD'] != "POST" && $tp_plugin && $template_id == 0 && 		$template_count > 0 && $action != 'open'){	require_once($GO_THEME->theme_path."header.inc");	echo '<form name="sendform" method="post" action="'.$_SERVER['PHP_SELF'].'">';	if($uid > 0)	{		//echo '<input type="hidden" name="account_id" value="'.$_REQUEST['account_id'].'" />';		echo '<input type="hidden" name="uid" value="'.$uid.'" />';		echo '<input type="hidden" name="mailbox" value="'.$_REQUEST['mailbox'].'" />';		echo '<input type="hidden" name="action" value="'.$_REQUEST['action'].'" />';	}	if(isset($_REQUEST['email_file']))	{		echo '<input type="hidden" name="email_file" value="true" />';	}	echo '<input type="hidden" name="mail_subject" value="'.$mail_subject.'" />';	echo '<input type="hidden" name="mail_body" value="'.smart_stripslashes($mail_body, true).'" />';	echo '<input type="hidden" name="mail_to" value="'.htmlspecialchars($mail_to,ENT_QUOTES).'" />';	echo '<input type="hidden" name="mail_cc" value="'.$mail_cc.'" />';	echo '<input type="hidden" name="mail_bcc" value="'.$mail_bcc.'" />';	echo '<input type="hidden" name="mail_from" value="'.$mail_from.'" />';	echo '<input type="hidden" name="contact_id" value="'.$contact_id.'" />';	echo '<input type="hidden" name="company_id" value="'.$company_id.'" />';	echo '<input type="hidden" name="template_id" />';	echo '<input type="hidden" name="mailing_group_id" value="'.$mailing_group_id.'" />';	echo '<input type="hidden" name="sendaction" value="load_template" />';	if($notification_check)	{		echo '<input type="hidden" name="notification" value="true" />';	}	//get the addressbook language file	require_once($GO_LANGUAGE->get_language_file('addressbook'));	$tabstrip = new tabstrip('templates_tab', $ab_templates);	$tabstrip->set_attribute('style','width:100%');	$tabstrip->add_html_element(new html_element('p', $ab_select_template));	$link = new hyperlink("javascript:document.forms[0].template_id.value=\'0\';document.forms[0].submit();",$ab_no_template);	$link->set_attribute('class','selectableItem');	$tabstrip->add_html_element($link);	while($tp->next_record())	{		$link = new hyperlink('javascript:document.forms[0].template_id.value=\''.$tp->f('id').'\';document.forms[0].submit();',$tp->f('name'));		$link->set_attribute('class','selectableItem');		$tabstrip->add_html_element($link);	}	$tabstrip->add_html_element(new button($cmdClose, "javascript:window.close()"));	echo $tabstrip->get_html();}else{	//reset attachments array in case user aborted a message or changed format	if ($_SERVER['REQUEST_METHOD'] != "POST" || $sendaction=='load_template')	{		if (!isset($_REQUEST['email_file']))		{			unset($_SESSION['attach_array']);			unset($_SESSION['url_replacements']);		}	}	$ids=array();	//get users email accounts to determine from addresses	$count = $email->get_accounts($GO_SECURITY->user_id);	while ($email->next_record())	{		if ($mail_from == 0)		{			$mail_from = $email->f('id');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -