Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c	(revision 353549)
+++ channels/chan_sip.c	(working copy)
@@ -748,6 +748,7 @@
 static int global_store_sip_cause;    /*!< Whether the MASTER_CHANNEL(HASH(SIP_CAUSE,[chan_name])) var should be set */
 
 static int global_dynamic_exclude_static = 0; /*!< Exclude static peers from contact registrations */
+static unsigned char global_refer_addheaders; /*!< Add extra headers to outgoing REFER */
 /*@}*/
 
 /*!
@@ -12161,13 +12162,11 @@
 	append_date(&req);
 	if (sipmethod == SIP_REFER) {	/* Call transfer */
 		if (p->refer) {
-			char buf[SIPBUFSIZE];
 			if (!ast_strlen_zero(p->refer->refer_to)) {
 				add_header(&req, "Refer-To", p->refer->refer_to);
 			}
 			if (!ast_strlen_zero(p->refer->referred_by)) {
-				snprintf(buf, sizeof(buf), "%s <%s>", p->refer->referred_by_name, p->refer->referred_by);
-				add_header(&req, "Referred-By", buf);
+				add_header(&req, "Referred-By", p->refer->referred_by);
 			}
 		}
 	} else if (sipmethod == SIP_SUBSCRIBE) {
@@ -12209,7 +12208,8 @@
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	add_supported_header(p, &req);
 
-	if (p->options && p->options->addsipheaders && p->owner) {
+	if (p->owner && ((p->options && p->options->addsipheaders)
+				  || (p->refer && p->refer->addsipheaders))) {
 		struct ast_channel *chan = p->owner; /* The owner channel */
 		struct varshead *headp;
 	
@@ -13426,9 +13426,6 @@
 */
 static int transmit_refer(struct sip_pvt *p, const char *dest)
 {
-	struct sip_request req = {
-		.headers = 0,	
-	};
 	char from[256];
 	const char *of;
 	char *c;
@@ -13474,18 +13471,10 @@
 	ast_copy_string(p->refer->refer_to, referto, sizeof(p->refer->refer_to));
 	ast_copy_string(p->refer->referred_by, p->our_contact, sizeof(p->refer->referred_by));
 	p->refer->status = REFER_SENT;   /* Set refer status */
+	p->refer->addsipheaders = global_refer_addheaders;
 
-	reqprep(&req, p, SIP_REFER, 0, 1);
+	return transmit_invite(p, SIP_REFER, FALSE, 0, NULL);
 
-	add_header(&req, "Refer-To", referto);
-	add_header(&req, "Allow", ALLOWED_METHODS);
-	add_supported_header(p, &req);
-	if (!ast_strlen_zero(p->our_contact)) {
-		add_header(&req, "Referred-By", p->our_contact);
-	}
-
-	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
-
 	/* We should propably wait for a NOTIFY here until we ack the transfer */
 	/* Maybe fork a new thread and wait for a STATUS of REFER_200OK on the refer status before returning to app_transfer */
 
@@ -28096,6 +28085,7 @@
 	global_qualifyfreq = DEFAULT_QUALIFYFREQ;
 	global_t38_maxdatagram = -1;
 	global_shrinkcallerid = 1;
+	global_refer_addheaders = TRUE;
 	authlimit = DEFAULT_AUTHLIMIT;
 	authtimeout = DEFAULT_AUTHTIMEOUT;
 	global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE;
@@ -28610,6 +28600,8 @@
 			ast_set2_flag(&global_flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC);
 		} else if (!strcasecmp(v->name, "parkinglot")) {
 			ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot));
+		} else if (!strcasecmp(v->name, "refer_addheaders")) {
+			global_refer_addheaders = ast_true(v->value);
 		}
 	}
 
Index: channels/sip/include/sip.h
===================================================================
--- channels/sip/include/sip.h	(revision 353549)
+++ channels/sip/include/sip.h	(working copy)
@@ -880,6 +880,7 @@
 	int attendedtransfer;                         /*!< Attended or blind transfer? */
 	int localtransfer;                            /*!< Transfer to local domain? */
 	enum referstatus status;                      /*!< REFER status */
+	unsigned char addsipheaders : 1;              /*!< Add extra SIP headers */
 };
 
 /*! \brief Struct to handle custom SIP notify requests. Dynamically allocated when needed */
Index: configs/sip.conf.sample
===================================================================
--- configs/sip.conf.sample	(revision 353549)
+++ configs/sip.conf.sample	(working copy)
@@ -464,7 +464,16 @@
 
 ;use_q850_reason = no ; Default "no"
                       ; Set to yes add Reason header and use Reason header if it is available.
+
+; When the Transfer() application sends a REFER SIP message, extra headers specified in
+; the dialplan by way of SIPAddHeader are sent out with that message. 1.8 and earlier did not
+; add the extra headers. To revert to 1.8- behavior, call SIPRemoveHeader with no arguments
+; before calling Transfer() to remove all additional headers from the channel. The setting
+; below is for transitional compatibility only.
 ;
+;refer_addheaders=yes	; on by default
+
+;
 ;------------------------ TLS settings ------------------------------------------------------------
 ;tlscertfile=</path/to/certificate.pem> ; Certificate file (*.pem format only) to use for TLS connections
                                         ; default is to look for "asterisk.pem" in current directory
