I am writing a wordpress plugin that utilizes the wp_mail function. However I wish to alter the From: address. Wordpress provides some filters - wp_mail_from_name and wp_mail_from - but I am unsure how you can give them a call from inside a category.

Basically put them outdoors of the function there is a parse error (unpredicted T_STRING, expecting T_FUNCTION).

Basically put them inside a function nothing appears to occur

class myPlugin {    
    public function setFromname($fromname) {
        apply_filters( 'wp_mail_from_name', $fromname );
        $this->fromname = $fromname;
    }
    public function setFromemail($fromemail) {
        apply_filters( 'wp_mail_from', $fromemail );
        $this->fromemail = $fromemail;
    }
}

How can you really affect these filters inside a Class?

In WordPress filters should have a phone call back, they are unable to make use of a variable.

class myPlugin {
    public function myPlugin {
        add_filter( 'wp_mail_from_name', array($this, 'filter_mail_from_name'));
        add_filter( 'wp_mail_from', array($this, 'filter_mail_from'));
    }

    function filter_mail_from_name( $from_name ) {
        // the $from_name comes from WordPress, this is the default $from_name
        // you must modify the $from_name from within this function before returning it
        return $from_name;
    }

    function filter_mail_from( $from_email ) {
        // the $from_email comes from WordPress, this is the default $from_name
        // you must modify the $from_email from within this function before returning it
        return $from_email;
    }
}