使用在 Hostinger (PHP) 上创建的电子邮件帐户发送邮件

问题描述 投票:0回答:3

我通过 PHPMailer 发送电子邮件,代码托管在托管商的 hpanel 上,我正在使用在 hpanel 上创建的电子邮件。运行代码后,我没有收到任何错误,也没有关于邮件是否已发送的反馈,它只是没有显示任何内容。

请帮助我,我现在不知道该怎么办。

        require '../../vendor/autoload.php';

        $mail = new PHPMailer(true);
        try
        {
            $mail->SMTPDebug = SMTP::DEBUG_SERVER;
            
            $mail->isSMTP();
            $mail->Host = 'smtp.titan.email';
            $mail->SMTPAuth = true;
            $mail->Username = '[email protected]';
            $mail->Password = 'password';
            $mail->SMTPSecure = 'SSL';
            $mail->Port = 465;

            $mail->setFrom('[email protected]', 'Hostinger');
            $mail->addAddress($email, $username);
            $mail->addReplyTo('[email protected]', 'For any Information');
            $mail->addCC('[email protected]');
            
            $mail->isHTML(true);
            $mail->Subject = 'Sending message';
            $mail->Body    = $message;
            $mail->AltBody = "Hello there";

            $mail->send();

            echo "Sent";
        }
        catch (Exception $eax) 
        {
            echo 'EMAIL SENDING FAILED. INFO: '.$mail->ErrorInfo;
        }
email phpmailer
3个回答
4
投票

无需使用 $mail->isSMTP();

注释$mail->isSMTP();


0
投票

确保您使用正确的 smtp 主机:

$mail->Host = 'smtp.hostinger.com'

0
投票

我的邮件服务器不是 smtp.hostinger.com 而是 titan(在 Hostinger 高级网络托管上):

//$mail->isSMTP();
$mail->Host = 'smtp.titan.email';
$mail->Port = 465;
© www.soinside.com 2019 - 2024. All rights reserved.