PHPMailer::set PHP Method

set() public method

You should avoid this function - it's more verbose, less efficient, more error-prone and harder to debug than setting properties directly. Usage Example: $mail->set('SMTPSecure', 'tls'); is the same as: $mail->SMTPSecure = 'tls';
public set ( string $name, mixed $value = '' ) : boolean
$name string The property name to set
$value mixed The value to set the property to
return boolean
    public function set($name, $value = '')
    {
        if (property_exists($this, $name)) {
            $this->{$name} = $value;
            return true;
        } else {
            $this->setError($this->lang('variable_set') . $name);
            return false;
        }
    }

Usage Example

Example #1
0
 /**
  * Send an email
  *
  * @param array  $recipient The recipient to send the mail to
  *                          Format:
  *                          array(
  *                              '*****@*****.**',
  *                              'test',
  *                          )
  * @param string $subject   The mail subjet
  * @param string $message   The mail message, may be html
  *
  * @return boolean
  */
 public static function send($recipient, $subject, $message)
 {
     $translator = \SmartWork\Translator::getInstance();
     $mailer = new \PHPMailer(true);
     $mailer->set('CharSet', $this->globalConfig->getConfig('charset'));
     $mailer->setFrom($this->globalConfig->getGlobal(array('mail' => 'sender')), $translator->gt('title'));
     $mailer->addAddress($recipient[0], $recipient[1]);
     $mailer->set('Subject', $subject);
     $mailer->set('AltBody', strip_tags($message));
     $mailer->msgHTML($message);
     $mailer->isHTML(true);
     return $mailer->send();
 }
All Usage Examples Of PHPMailer::set