使用PHPMailer通过Kimsufi服务器发送SMTP邮件
问题描述:
我有一台使用Debian的Kimsufi(OVH)服务器。使用PHPMailer通过Kimsufi服务器发送SMTP邮件
我想使用PHPMailer library发送SMTP电子邮件。
我不知道用户名和密码应该是什么。
$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
如何获取所需的用户名和密码?
答
用户名和密码将是发件人的电子邮件详细信息。它会询问你想通过哪个邮件地址通过phpmailer发送邮件。由于phpmailer库需要使用SMTP用户名&密码来发送邮件并确认收件箱传送。不仅如此,它还需要SMTP服务器&认证详情。
让我们使用个人Gmail帐户通过的PHPMailer发送邮件在这种情况下,你的代码会是这样
$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 = '[email protected]'; // 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
感谢@Sachin,但我不希望使用个人电子邮件帐户发送电子邮件。我想用我的专用服务器。这是问题所在。 – Macbernie
如果您想要在您的域名中使用电子邮件地址,请在该域名下创建一个电子邮件地址,并设置用户名和密码,而不是谷歌地址。或者让我知道域名会给你所有的信息使用 –