settings->all( MailConfig::SCOPE ); return 'smtp' === $values['mode'] && '' !== $values['host'] && array() === OtherMailers::active(); } /** * Points PHPMailer at the SMTP server. * * @param mixed $phpmailer PHPMailer instance. */ public function configure( $phpmailer ): void { if ( ! $phpmailer instanceof \PHPMailer\PHPMailer\PHPMailer || ! $this->in_charge() ) { return; } $values = $this->settings->all( MailConfig::SCOPE ); // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- PHPMailer's own property names. $phpmailer->isSMTP(); $phpmailer->Host = (string) $values['host']; $phpmailer->Port = (int) $values['port']; $phpmailer->SMTPSecure = 'none' === $values['encryption'] ? '' : (string) $values['encryption']; $phpmailer->SMTPAutoTLS = 'none' !== $values['encryption']; $phpmailer->SMTPAuth = (bool) $values['auth']; if ( $phpmailer->SMTPAuth ) { $phpmailer->Username = (string) $values['username']; $phpmailer->Password = $this->vault->unlock( (string) $values['password_locked'] ); } // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase } /** * The sender address, when one is set. * * @param mixed $email Address WordPress would use. * @return mixed */ public function from_email( $email ) { $value = (string) $this->settings->get( MailConfig::SCOPE, 'from_email', '' ); return $this->in_charge() && '' !== $value ? $value : $email; } /** * The sender name, when one is set. * * @param mixed $name Name WordPress would use. * @return mixed */ public function from_name( $name ) { $value = (string) $this->settings->get( MailConfig::SCOPE, 'from_name', '' ); return $this->in_charge() && '' !== $value ? $value : $name; } }