Sender name surrounded with double-quotes

I have a WordPress site using the Gravity Forms plugin and Send Grid via the PostSMTP plugin.

Notification messages sent from the site when a form is submitted seem to surround the sender’s name in double quotes:
"Any Name" <info@domain-redacted.com>

I have changed the sender name in Gravity Forms, but it always gets quotes - even with no sender name, it puts quotes around the email address.:
"info@domain-redacted.com" <info@domain-redacted.com>

This is a message sent from the site to a visitor who has completed the form as an acknowledgement. Any ideas how to remove the double-quotes?

OK - I solved this problem myself…

The quotes are added by Gravity Forms directly.

In common.php (version 2.8.0) I changed line 2313 from this

$headers['From'] = 'From: "' . wp_strip_all_tags( $name, true ) . '" <' . $from . '>';

To this:

$headers['From'] = 'From: ' . wp_strip_all_tags( $name, true ) . ' <' . $from . '>';```

You should not edit the plugin files.

You can use the gform_pre_send_email filter to remove the quotes just before the notification is passed to WordPress for delivery.

The filter would be used in the theme functions.php file, a custom plugin, or with a code snippets plugin.

Ah ok - I’ll look into this, though it does seem like a bug in the first place. Why are the double quotes there?

Appreciate it’s a bad idea to edit the plugin files directly as they’ll be overwritten when the plugin is updated and could potentially cause other issues too :+1:

I have restored the original plugin files and implemented a filter as follows. This seems to solve the issue.

add_filter( 'gform_pre_send_email', 'pad_remove_gforms_quotes', 10, 4 );
	function pad_remove_gforms_quotes($email){
		$headers = $email["headers"];
		$from = $headers["From"];
		$headers["From"] = str_replace('"','',$from);
		$email["headers"] = $headers;
		return $email;
	}

It isn’t a bug. According to the specification for how the From header is defined, the use of quotes around the name is optional but recommended when the name can contain special characters, spaces, or certain punctuation marks. The quotes help ensure proper parsing and interpretation of the header by email clients and servers.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.