• Resolved eupalinos

    (@eupalinos)


    Hi, Alo.

    I’m trying to create a mu-plugin to send a custom activation email based on a “activation.php” (html + images) file, but of course it doesn’t work. Do you have any idea why? I copied the entire section from the alo-easymail-mailer.php file and edited it to no avail.

    <?php
    
    function alo_em_handle_custom_activation_email ( $args ) {
    	// $args['to'], $args['subject'], $args['message'], $args['headers'], $args['attachments']
    
    	// Check based on $args['subject']; more attrs in $args['message']
    	global $_config;
    	/*
    	 * 1) Activation e-mail
    	 */
    	if ( strpos ( "#_EASYMAIL_ACTIVATION_#", $args['subject'] ) !== false) {
    
    		// Get the parameters stored as a query in $args['message']
    		$defaults = array( 'lang' => '', 'email' => '',	'name' => '', 'unikey' => '' );
    		/* // replaced 'wp_parse_args' because use urlencode and stripslashes, so affect emails with '+' chars
    		$customs = wp_parse_args( $args['message'], $defaults );
    		extract( $customs, EXTR_SKIP );
    		*/
    		$pars = array();
    		$raw = explode('&', $args['message']);
    		foreach ($raw as $section)
    		{
    			if (strpos($section, '=') !== false)
    			{
    				list($key, $value) = explode('=', $section);
    				$pars[$key] = $value;
    			}
    		}
    		$customs = array_merge( $defaults, $pars );
    		extract( $customs, EXTR_SKIP );
    
    		// Subject
    		if ( $subject_text = alo_em_translate_option ( $lang, 'alo_em_txtpre_activationmail_subj', true ) ) {
    			$subject = $subject_text;
    		} else {
    			$subject = alo_em___( __("This is a custom activation email", "alo-easymail" ) );
    		}
    		$args['subject'] = $subject;
    
    		// Content
    		if ( $content_txt = alo_em_translate_option ( $lang, 'alo_em_txtpre_activationmail_mail', true ) ) {
    			$content = $content_txt;
    		} else {
    		$content = file_get_contents(WP_CONTENT_DIR . '/uploads/activation.php');
    		}
    
    		$sub_vars = $email ."|" /*$div_email[0] . "|" . $div_email[1] . "|" */ . $unikey . "|" . $lang;
    
    		//$sub_vars = $subscriber->ID . "|" . $subscriber->unikey;
    		$sub_vars = urlencode( base64_encode( $sub_vars ) );
    		$sub_link = add_query_arg( 'emact', $sub_vars, alo_em_translate_home_url ( $lang ) );
    
    		$content = str_replace ( "%ACTIVATIONLINK%", $sub_link, $content );
    
    		$args['message'] = $content;
    	}
    	return $args;
    }
    
    add_filter('wp_mail', 'alo_em_handle_custom_activation_email');
    ?>

    Thank you.

Viewing 1 replies (of 1 total)
  • Thread Starter eupalinos

    (@eupalinos)

    I only had to tweak the chunk above some more, and now it works. I can send a custom activation email as a complete html file.

    You can mark this thread as solved, too.

    Thank you.

    Marco.

Viewing 1 replies (of 1 total)

The topic ‘Custom Activation Email’ is closed to new replies.