通过Kimsufi Server使用PHPMailer发送SMTP电子邮件

I have a Kimsufi (OVH) server with Debian.

I want to use the PHPMailer library to send SMTP emails.

I have no idea what the username and password should be.

    $this->mail->isSMTP();               // Set mailer to use SMTP
    $this->mail->CharSet = 'UTF-8';
    $this->mail->Host = 'my server ip';  // Specify main and backup SMTP servers
    $this->mail->SMTPAuth = true;        // Enable SMTP authentication
    $this->mail->Username = '';          // SMTP username
    $this->mail->Password = '';          // SMTP password
    $this->mail->SMTPSecure = '';        // Enable TLS encryption, `ssl` also accepted
    $this->mail->Port = 25;              // TCP port to connect to

How can I get the required username and password?

Username and password would be the sender email details. It is asking through which email address you would like to send mails via phpmailer. Since phpmailer library require SMTP username & password to send out mail and to confirm the inbox delivery. Not only that it also require SMTP server & authentication details.

Let's use personal gmail account to send mail via phpmailer in that case your code would be like this

$this->mail->isSMTP();               // Set mailer to use SMTP
$this->mail->CharSet = 'UTF-8';
$this->mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$this->mail->SMTPAuth = true;        // Enable SMTP authentication
$this->mail->Username = 'gmailemail@gmail.com';          // SMTP username
$this->mail->Password = 'yourgmailpassword';          // SMTP password
$this->mail->SMTPSecure = 'tls';        // Enable TLS encryption, `ssl` also accepted
$this->mail->Port = 587;              // TCP port to connect to