diff --git a/modules/Contacts/Contacts.php b/modules/Contacts/Contacts.php
index 61e4c11efb67653ecb9a04eab5b4fc4f31790997..68f72ce4ff8ac2beed875f4cf32e4007731b349b 100644
--- a/modules/Contacts/Contacts.php
+++ b/modules/Contacts/Contacts.php
@@ -1537,13 +1537,6 @@ function get_contactsforol($user_name)
 		$contents = str_replace('$support_team$',getTranslatedString('Support Team', $moduleName),$contents);
 		$contents = str_replace('$logo$','<img src="cid:logo" />',$contents);
 
-		//Company Details
-		$contents = str_replace('$address$',$companyDetails['address'],$contents);
-		$contents = str_replace('$companyname$',$companyDetails['companyname'],$contents);
-		$contents = str_replace('$phone$',$companyDetails['phone'],$contents);
-		$contents = str_replace('$companywebsite$',$companyDetails['website'],$contents);
-		$contents = str_replace('$supportemail$',$HELPDESK_SUPPORT_EMAIL_ID,$contents);
-
 		if($type == "LoginDetails") {
 			$temp=$contents;
 			$value["subject"]=decode_html($adb->query_result($result,0,'subject'));
diff --git a/modules/Migration/schema/720_to_721.php b/modules/Migration/schema/720_to_721.php
index 4d156c7faa1d712e6849aebbfb93ba8a22975658..002d1612b9de4b4b9b9def55b50479173ddc6042 100644
--- a/modules/Migration/schema/720_to_721.php
+++ b/modules/Migration/schema/720_to_721.php
@@ -145,4 +145,71 @@ if (defined('VTIGER_UPGRADE')) {
     
     $em->registerHandler('vtiger.entity.afterrelate', 'modules/Vtiger/handlers/RelateEntitesHandler.php', 'RelateEntitesHandler');
 	echo '<br>Succecssfully added before relate handler<br>';
+    
+    //Updating customer-portal email template
+    $result = $db->pquery("SELECT templateid FROM vtiger_emailtemplates WHERE subject = ?", array('Customer Portal Login Details'));
+    if ($db->num_rows($result)) {
+        $templateId = $db->query_result($result, 0, 'templateid');
+    }
+    if(!empty($templateId)){
+        $portalLoginTemplateRecord = EmailTemplates_Record_Model::getInstanceById($templateId);
+        $portalLoginTemplateContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+        <html>
+        <head>
+          <title></title>
+        </head>
+        <body class="scayt-enabled">
+          <!-- <center> -->
+            <table border="0" cellpadding="0" cellspacing="0" class="borderGrey" width="600px" style="margin-left:0px;">
+              <tbody>
+                <tr>
+                  <td colspan="6"><!-- Begin Pre header --><!-- // End Pre header \ --></td>
+                </tr>
+                <tr style="height:50px;">
+                  <td colspan="6" style="
+                  font-family: Helvetica,Verdana,sans-serif">
+                  <div style="margin-bottom:10px;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);"><br />
+                    Dear $contacts-firstname$ $contacts-lastname$,</div>
+
+                    <div style="margin-top:20px;margin-bottom:20px; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">As our customer, you can be assured of getting excellent support from our team. I would like to take this opportunity to introduce the portal we have setup for valuable customers like you. You can submit questions/issues via the portal, see past issues and responses. In addition, Portal provides you access to our knowledge base and documents we shared with you in the past.
+                    </div>
+
+                    <div style="margin-top:10px;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">$URL$ to login to the portal, with the credentials below.</div>
+
+                    <div style="margin-top:20px;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">Your Username: $login_name$</div>
+
+                    <div style="margin-bottom:20px;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">Your Password: $password$</div>
+                    <div class="gmail_extra" style="margin-top:10px;color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">Thank you,<br />
+                      $contacts-smownerid$</div>
+
+                    </td>
+                  </tr>
+                  <tr>
+                    <td colspan="6" style="font-family: Helvetica,Verdana,sans-serif;font-size: 11px;color: #666666;">
+                      <table border="0" cellpadding="4" cellspacing="0" width="100%">
+                        <tbody>
+                          <!--copy right data-->
+                          <tr>
+                            <td valign="top" style="
+                            padding-left: 0px;
+                            padding-right: 0px;
+                            width:350px">
+                                <div style="margin-top:20px;"><em>Powered By <a href="www.vtiger.com">Vtiger</a><div>
+                            </td>
+                          </tr>
+                          <!--subscribers links-->
+                        </tbody>
+                      </table>
+                    </td>
+                  </tr>
+                </tbody>
+              </table>
+            <!-- </center> -->
+          </body>
+          </html>';
+        $portalLoginTemplateRecord->set('body', $portalLoginTemplateContent);
+        $portalLoginTemplateRecord->save();
+        $portalLoginTemplateId = $portalLoginTemplateRecord->getId();
+        echo "Customer portal login template created.<br>";
+    }
 }
\ No newline at end of file
diff --git a/packages/vtiger/optional/RecycleBin.zip b/packages/vtiger/optional/RecycleBin.zip
index 4f3185ef3283bd897637630d31ec42ff5729a4b0..7e3e466fd944223d94cf207c1a19c062dde04f6b 100644
Binary files a/packages/vtiger/optional/RecycleBin.zip and b/packages/vtiger/optional/RecycleBin.zip differ
diff --git a/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php b/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php
index d9dfed4d51316eee4675d4fd95e6b6be6e6ac0dd..d2e4f35ccc0d99f16eaf04bdf79f32c7b35843c9 100644
--- a/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php
+++ b/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php
@@ -152,6 +152,7 @@ class RecycleBin_Module_Model extends Vtiger_Module_Model {
         
         // Delete related mod comments
 		$this->deleteRelatedComments($recordIds);
+        $this->deleteRelatedEmails($recordIds);
 
 		// TODO - Remove records from module tables and other related stores.
 		$query = 'DELETE FROM vtiger_modtracker_basic WHERE crmid in(' . generateQuestionMarks($recordIds) . ')';
@@ -256,4 +257,25 @@ class RecycleBin_Module_Model extends Vtiger_Module_Model {
 
 		$db->pquery($query, array($recordIds));
 	}
+    
+    /**
+	 * Function to remove emails related to given records
+	 * @param type $recordIds
+	 */
+	public function deleteRelatedEmails($recordIds) {
+		$db = PearDatabase::getInstance();
+		/**
+		 *  we have to delete emails if email is related to any $recordIds and same email is 
+		 *  not related to another record
+		 */
+		$query = "DELETE vtiger_crmentity.* FROM vtiger_crmentity INNER JOIN "
+				. "(SELECT vtiger_crmentity.crmid AS actid,vtiger_seactivityrel.crmid AS relid "
+				. "FROM vtiger_crmentity INNER JOIN vtiger_seactivityrel ON "
+				. "vtiger_seactivityrel.activityid=vtiger_crmentity.crmid "
+				. "GROUP BY vtiger_seactivityrel.activityid HAVING count(vtiger_seactivityrel.activityid) = 1)"
+				. " AS relationdata ON relationdata.actid=vtiger_crmentity.crmid "
+				. "WHERE relationdata.relid IN (" . generateQuestionMarks($recordIds) . ")";
+
+		$db->pquery($query, array($recordIds));
+	}
 }