Back to Mail class

Method useSmtp

public bool
useSmtp
(mixed $auth = null, mixed $host = null, mixed $user = null, mixed $pass = null, mixed $secure = null, mixed $port = 25)
Use SMTP for sending the email
Parameters
  • string $auth SMTP Authentication [optional]
  • string $host SMTP Host [optional]
  • string $user SMTP Username [optional]
  • string $pass SMTP Password [optional]
  • string $secure Use secure methods
  • int $port The SMTP port
Returns
  • bool True on success
Since
  • 1.7.0
Class: Mail
Project: Joomla

Method useSmtp - Source code

/**
 * Use SMTP for sending the email
 *
 * @param   string   $auth    SMTP Authentication [optional]
 * @param   string   $host    SMTP Host [optional]
 * @param   string   $user    SMTP Username [optional]
 * @param   string   $pass    SMTP Password [optional]
 * @param   string   $secure  Use secure methods
 * @param   integer  $port    The SMTP port
 *
 * @return  boolean  True on success
 *
 * @since   1.7.0
 */
public function useSmtp($auth = null, $host = null, $user = null, $pass = null, $secure = null, $port = 25)
{
    $this->SMTPAuth = $auth;
    $this->Host = $host;
    $this->Username = $user;
    $this->Password = $pass;
    $this->Port = $port;
    if ($secure === 'ssl' || $secure === 'tls') {
        $this->SMTPSecure = $secure;
    }
    if ($this->SMTPAuth !== null && $this->Host !== null && $this->Username !== null && $this->Password !== null || $this->SMTPAuth === null && $this->Host !== null) {
        $this->isSMTP();
        return true;
    } else {
        $this->isMail();
        return false;
    }
}