diff --git a/apps/app_voicemail2.c b/apps/app_voicemail2.c
index 24ece10348b68932b116717c776590203dc88d97..9f7a4ff4fb26b344c52dfef6369965a6d09509d7 100755
--- a/apps/app_voicemail2.c
+++ b/apps/app_voicemail2.c
@@ -15,6 +15,7 @@
 #include <asterisk/file.h>
 #include <asterisk/logger.h>
 #include <asterisk/channel.h>
+#include <asterisk/channel_pvt.h>
 #include <asterisk/pbx.h>
 #include <asterisk/options.h>
 #include <asterisk/config.h>
@@ -143,6 +144,10 @@ static int maxgreet;
 static int skipms;
 static int maxlogins;
 
+static char *emailbody = NULL;
+static int pbxskip = 0;
+static char fromstring[15];
+
 STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
@@ -585,9 +590,16 @@ static int sendmail(char *srcemail, char *email, char *name, int msgnum, char *m
 		localtime_r(&t,&tm);
 		strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm);
 		fprintf(p, "Date: %s\n", date);
-		fprintf(p, "From: Asterisk PBX <%s>\n", who);
+		
+		if (*fromstring)
+			fprintf(p, "From: %s <%s>\n", fromstring, who);
+		else
+			fprintf(p, "From: Asterisk PBX <%s>\n", who);
 		fprintf(p, "To: %s <%s>\n", name, email);
-		fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum, mailbox);
+		if (pbxskip)
+			fprintf(p, "Subject: New message %d in mailbox %s\n", msgnum, mailbox);
+		else
+			fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum, mailbox);
 		fprintf(p, "Message-ID: <Asterisk-%d-%s-%d@%s>\n", msgnum, mailbox, getpid(), host);
 		fprintf(p, "MIME-Version: 1.0\n");
 		if (attach_user_voicemail) {
@@ -600,11 +612,32 @@ static int sendmail(char *srcemail, char *email, char *name, int msgnum, char *m
 		}
 		fprintf(p, "Content-Type: TEXT/PLAIN; charset=US-ASCII\n\n");
 		strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
-		fprintf(p, "Dear %s:\n\n\tJust wanted to let you know you were just left a %s long message (number %d)\n"
+		if (emailbody) {
+			struct ast_channel *ast = ast_channel_alloc(0);
+			if (ast) {
+				char *passdata;
+				int vmlen = strlen(emailbody)*2;
+				if (vmlen < 20)
+					vmlen = 100;
+				passdata = alloca(vmlen);
+				pbx_builtin_setvar_helper(ast, "VM_NAME", name);
+				pbx_builtin_setvar_helper(ast, "VM_DUR", dur);
+				sprintf(passdata,"%d",msgnum);
+				pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata);
+				pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox);
+				pbx_builtin_setvar_helper(ast, "VM_CALLERID", (callerid ? callerid : "an unknown caller"));
+				pbx_builtin_setvar_helper(ast, "VM_DATE", date);
+				pbx_substitute_variables_helper(ast,emailbody,passdata,vmlen);
+				fprintf(p, "%s\n",passdata);
+				ast_channel_free(ast);
+			} else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
+		} else {
+			fprintf(p, "Dear %s:\n\n\tJust wanted to let you know you were just left a %s long message (number %d)\n"
 
 			"in mailbox %s from %s, on %s so you might\n"
 			"want to check it when you get a chance.  Thanks!\n\n\t\t\t\t--Asterisk\n\n", name, 
 			dur, msgnum, mailbox, (callerid ? callerid : "an unknown caller"), date);
+		}
 		if (attach_user_voicemail) {
 			fprintf(p, "--%s\n", bound);
 			fprintf(p, "Content-Type: audio/x-wav; name=\"msg%04d.%s\"\n", msgnum, format);
@@ -2533,6 +2566,38 @@ static int load_config(void)
 			cat = ast_category_browse(cfg, cat);
 		}
 #endif
+		memset(fromstring,0,sizeof(fromstring));
+		if (emailbody) {
+			free(emailbody);
+			emailbody = NULL;
+		}
+		if ((s=ast_variable_retrieve(cfg, "general", "pbxskip")))
+			pbxskip = ast_true(s);
+		if ((s=ast_variable_retrieve(cfg, "general", "fromstring")))
+			strncpy(fromstring,s,sizeof(fromstring)-1);
+		if ((s=ast_variable_retrieve(cfg, "general", "emailbody"))) {
+			char *tmpread, *tmpwrite;
+			emailbody = strdup(s);
+
+			/* substitute strings \t and \n into the apropriate characters */
+			tmpread = tmpwrite = emailbody;
+			while ((tmpwrite = strchr(tmpread,'\\'))) {
+				int len = strlen("\n");
+				switch (tmpwrite[1]) {
+					case 'n':
+						strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
+						strncpy(tmpwrite,"\n",len);
+						break;
+					case 't':
+						strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
+						strncpy(tmpwrite,"\t",len);
+						break;
+					default:
+						ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n",tmpwrite[1]);
+				}
+				tmpread = tmpwrite+len;
+			}
+		}
 		ast_destroy(cfg);
 		ast_pthread_mutex_unlock(&vmlock);
 		return 0;
diff --git a/configs/voicemail.conf.sample b/configs/voicemail.conf.sample
index de6b6680e8ab6df4fb1f0fab6076b9750e44955a..4c2527dfd7e9a4fb779b167981df6b5478e8abd4 100755
--- a/configs/voicemail.conf.sample
+++ b/configs/voicemail.conf.sample
@@ -23,6 +23,13 @@ silencethreshold=128
 ; Max number of failed login attempts
 maxlogins=3
 
+; Skip the "[PBX]:" string from the message title
+;pbxskip=yes
+; Change the From: string
+;fromstring=The Asterisk PBX
+; Change the email body, variables: VM_NAME, VM_DUR, VM_MSGNUM, VM_MAILBOX, VM_CALLERID, VM_DATE
+;emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE} so you might\nwant to check it when you get a chance.  Thanks!\n\n\t\t\t\t--Asterisk\n
+
 ;
 ; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>,<options>
 ; if the e-mail is specified, a message will be sent when a message is
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index de7c00ec6ea980b37961ed5613cf786ba7b880a6..fa2c5131b23f4620cdeb3f255b4ccfb22502d489 100755
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -505,6 +505,7 @@ struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw
 extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
 extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
 extern void pbx_builtin_clear_globals(void);
+extern void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }