Index: apps/app_voicemail.c
===================================================================
--- apps/app_voicemail.c	(revision 105208)
+++ apps/app_voicemail.c	(working copy)
@@ -175,6 +175,8 @@
 #define	VOICEMAIL_FILE_MODE	0666
 #define	CHUNKSIZE	65536
 
+#define MAX_FORWARD_MESSAGE_RECEIVER_STRING 1024
+
 #define VOICEMAIL_CONFIG "voicemail.conf"
 #define ASTERISK_USERNAME "asterisk"
 
@@ -3036,7 +3038,8 @@
 	char fmt[80];
 	char *context;
 	char ecodes[17] = "#";
-	char tmp[1024] = "", *tmpptr;
+	char tmp[MAX_FORWARD_MESSAGE_RECEIVER_STRING] = "";
+	char *tmpptr;	
 	struct ast_vm_user *vmu;
 	struct ast_vm_user svm;
 	const char *category = NULL, *code, *alldtmf = "0123456789ABCD*#";
@@ -4283,12 +4286,17 @@
 	int valid_extensions = 0;
 	char *dir;
 	int curmsg;
+	int add_recipient = 0;
+	char recipients[MAX_FORWARD_MESSAGE_RECEIVER_STRING];
+ 
+	bzero(recipients,MAX_FORWARD_MESSAGE_RECEIVER_STRING);
 
 	if (vms == NULL) return -1;
 	dir = vms->curdir;
 	curmsg = vms->curmsg;
 	
 	while (!res && !valid_extensions) {
+		add_recipient = 0;
 		int use_directory = 0;
 		if (ast_test_flag((&globalflags), VM_DIRECFORWARD)) {
 			int done = 0;
@@ -4404,27 +4412,103 @@
 			s = strsep(&stringp, "*");
 		}
 		/* break from the loop of reading the extensions */
-		if (valid_extensions)
+		if (valid_extensions) {
+			int done = 0;
+			int retries = 0;
+
+			while ((cmd >= 0) && !done) {
+				cmd = 0;
+				while ((cmd >= 0) && !done ) {
+					if (cmd) 
+						retries = 0;
+
+					switch (cmd) {
+					case '1':
+						add_recipient = 0;
+						done = 1;
+						break;
+	
+					case '2':
+						add_recipient = 1;
+						done=1;
+						break;
+	
+					case '*':
+						cmd = 't';
+						done = 1;
+						break;
+	
+					default:
+						/* Press 1 to enter an send message, press 2 add another recipient */
+						cmd = ast_play_and_wait(chan,"vm-forward-multiple");
+						if (!cmd)
+							cmd = ast_waitfordigit(chan,3000);
+	
+						if (!cmd) 
+							retries++;
+	
+						if (retries > 3) {
+							cmd = 't';
+							done = 1;
+						}
+					} /* switch	*/
+	
+				} /* while reading multiple receiver prompt */
+			
+				if (cmd == 't') {
+					valid_extensions = 1;
+					break;
+				}
+
+				/* build recipient string */
+				char mailbox[AST_MAX_EXTENSION * 2 + 2];
+
+				/* Make sure that context doesn't get set as a literal "(null)" (or else find_user won't find it) */
+				if (context)
+					snprintf(mailbox, sizeof(mailbox), "%s@%s", username, context);
+				else
+					ast_copy_string(mailbox, username, sizeof(mailbox));
+
+				/* make sure we can actually add another recipient, play an error message if adding this recipient would be too large */
+				if (strlen(recipients) + strlen(mailbox) + 1  >= MAX_FORWARD_MESSAGE_RECEIVER_STRING && add_recipient == 1) {
+					res = ast_play_and_wait(chan, "vm-forward-multiple-too-many");
+					done = 0;
+					ast_log(LOG_DEBUG, "adding another recipient would exceed max length of recipient buffer of %d (current size is %d)\n", MAX_FORWARD_MESSAGE_RECEIVER_STRING, strlen(recipients));
+				} else {
+					/* append the currently entered mailbox to the recipients string. */
+					
+					if ( strlen(recipients) > 0)
+						strcat(recipients, "&");
+					
+					strcat(recipients, mailbox);
+
+					if (add_recipient == 1) 
+						valid_extensions = 0;
+					else 
+						valid_extensions = 1;
+		
+					done = 1; 
+				}
+			} /* while !done reading multiple recipients. */
+		}
+		if (valid_extensions) 
 			break;
+
 		/* "I am sorry, that's not a valid extension.  Please try again." */
-		res = ast_play_and_wait(chan, "pbx-invalid");
+		if (!add_recipient) 
+			res = ast_play_and_wait(chan, "pbx-invalid");
+
 	}
 	/* check if we're clear to proceed */
 	if (AST_LIST_EMPTY(&extensions) || !valid_extensions)
 		return res;
 	if (flag==1) {
 		struct leave_vm_options leave_options;
-		char mailbox[AST_MAX_EXTENSION * 2 + 2];
-		/* Make sure that context doesn't get set as a literal "(null)" (or else find_user won't find it) */
-		if (context)
-			snprintf(mailbox, sizeof(mailbox), "%s@%s", username, context);
-		else
-			ast_copy_string(mailbox, username, sizeof(mailbox));
 
 		/* Send VoiceMail */
 		memset(&leave_options, 0, sizeof(leave_options));
 		leave_options.record_gain = record_gain;
-		cmd = leave_voicemail(chan, mailbox, &leave_options);
+		cmd = leave_voicemail(chan, recipients, &leave_options);
 	} else {
 		/* Forward VoiceMail */
 		long duration = 0;
