# flywp/1.1/includes/Email.php

FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel, version 1.1. 63 lines.

- Page: https://pluginprobe.com/plugins/flywp/1.1/code/includes/Email.php
- Raw: https://pluginprobe.com/plugins/flywp/1.1/raw/includes/Email.php
- Modified: 2024-02-06T13:32:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/flywp/1.1/code/includes/Email.php#L10-L20`.

```php
<?php

namespace FlyWP;

class Email {

    /**
     * Class constructor.
     */
    public function __construct() {
        add_filter( 'wp_mail_from', [ $this, 'mail_from' ], PHP_INT_MAX );
        add_filter( 'wp_mail_from_name', [ $this, 'mail_from_name' ], PHP_INT_MAX );
    }

    /**
     * Set the from email.
     *
     * @param string $email
     *
     * @return string
     */
    public function mail_from( $email ) {
        $settings = $this->settings();

        if ( ! empty( $settings['from_email'] ) ) {
            return $settings['from_email'];
        }

        return $email;
    }

    /**
     * Set the from name.
     *
     * @param string $name
     *
     * @return string
     */
    public function mail_from_name( $name ) {
        $settings = $this->settings();

        if ( ! empty( $settings['from_name'] ) ) {
            return $settings['from_name'];
        }

        return $name;
    }

    /**
     * Get all email settings.
     *
     * @return array
     */
    public function settings() {
        $default = [
            'from_name'  => '',
            'from_email' => '',
        ];

        return get_option( 'flywp_email_settings', $default );
    }
}

```
