Issues with headers including bug

Hi,

We are trying to use the Subscribe by Email plugin (version 2.7.5) and have found a couple issues that we could use your help with:
1. Malformed List-Unsubscribe header
a. The list unsubscribe header is missing a trailing slash, currently it appears as: “List-Unsubscribe: <http://blogs.imms.com?sbe_unsubscribe=dedac98a4aeab6fa>”
b. It should appear as “List-Unsubscribe: <http://blogs.imms.com/?sbe_unsubscribe=dedac98a4aeab6fa>”
c. This could be a regression bug as the change log indicated that it might have been fixed in “1.1.4.1 - 07/13/2012 - S H Mohanjith”
2. “Reply-To:” header has same value as “To:” header
a. This configuration is not explicitly mentioned in IETF RFCs regarding email, but it can result in difficulty getting through spam filters. I can understand that it was set up this way to make it easier to use the plugin for the average user since they will not have to create an inbound email box, but it will create issues for larger lists. Can this be modified to allow a custom value to be input, or at the minimum an option to turn the “Reply-To” value off completely?
b. RFC 2822 section 3.6.2 “In the absence of the "Reply-To:" field, replies SHOULD by default be sent to the mailbox(es) specified in the "From:" field unless otherwise specified by the person composing the reply.”
3. Message-ID header
a. When the plugin is used the message ID header uses the generating systems FQDN. While this is only supposed to be used to guarantee the uniqueness of the message it would be nice to be able to customize it to a specific domain on the right hand side of the ‘@’. This would enable the plugin user to guarantee that the domain used was not also used for personal email, in other words, it would allow for further separation of bulk, marketing, or commercial email streams from transactional email streams.

  • Ignacio

    Hi @Erin.

    Latest version of the plugin (2.8.2) includes several changes that allows headers modifications.

    The List-Unsubscribe now includes a trailing slash at the end.

    For the rest of points that you said I opted for adding several hooks.

    - If you want to change the Reply-To header you can use the following code:

    add_filter( 'sbe_template_mail_headers', 'my_function_name', 10, 2 );
    function my_function_name( $headers ) {
    	$headers['reply-to'] = 'whatever@email.com';
    	return $headers;
    }

    - However, for the message ID this should be treated differently. Here's an example:

    add_action( 'sbe_before_send_single_email', 'my_function_set_phpmailer_init_hooks', 10, 2 );
    function my_function_set_phpmailer_init_hooks( $user_content, $user_email ) {
    	static $u_content;
    	// User content has the list of posts that we are going to send to the user
    	$u_content = $user_content;
    
    	static $u_email;
    	$u_email = $user_email;
    
    	// In this function we only set the hooks to change the PHP Mailer object
    	add_action( 'phpmailer_init', 'my_function_set_message_id' );
    }
    
    function my_function_set_message_id( &$phpmailer ) {
    	static $u_content;
    	static $u_email;
    
    	$msg_id = // Set here your message ID, you can base on the user content or user email
    
    	$phpmailer->MessageID = $msg_id . '@whatever.com';
    }
    
    // Do not forget to remove the action!
    add_action( 'sbe_before_send_single_email', 'my_function_remove_phpmailer_init_hooks' );
    function my_function_set_phpmailer_init_hooks( $user_content, $user_email ) {
    	remove_action( 'phpmailer_init', 'my_function_set_message_id' );
    }

    Let me know if this works for you.

    Regards.
    Ignacio.