PHP:使用邮件发送 link 无法正常工作

PHP: sending link with mail don't work correctly

我正在建立一个网站,我需要在用户注册时发送一封电子邮件。

电子邮件发送没有问题,但在我的 "href='link' or src='link'" 上,link 邮件中断。

代码如下:

<?php
    $to = $UserMail;
    $subject = 'XYZ - Account Verification'; 

    $headers = array("From: XYZ <noreply@XYZ.net>",
                    "Content-type: text/html; charset=ISO-8859-1",
                    "Mime-Version: 1.0",
                    "Content-Transfer-Encoding: quoted-printable",
                    "X-Mailer: PHP/" . PHP_VERSION
    );

    $headers = implode("\r\n", $headers);

    //define the message to be sent. Each line should be separated with \n
    $IDVer = crypt($UserID, 'a$YourSaltIsA22ChrString$');
    $message = "<html>
                    <img src='https://www.example.net/path/image.png' width='1200' height='1200' alt='Logo'>
                    <h1> Hi " . $Username . " welcome to XYZ!</h1><br>
                    Please Verify your account clicking
                    <a href='https://www.example.net/path/?Verify=". $IDVer ."'> here</a>
                </html>";


    $mail_sent = SendEmail($to, $subject, $message, $headers);
    if($mail_sent){
        $success = 'Mail send!';
    }else{
        $Error = 'Mail Error: ' . error_get_last()['message'] . ' on line: '. error_get_last()['line'] . ' on file: '. error_get_last()['file']. ' Error type: ' . error_get_last()['type'];
    }
?>

这是 SendEmail() 函数:

<?php
ini_set('SMTP','smtp.zoho.com');
ini_set('smtp_port',465);
ini_set('sendmail_from', 'noreply@XYZ.net');



//send the email
function SendEmail($to, $subject, $message, $headers){
    $mail_sent = mail($to, $subject, $message, $headers);
}
?>

邮件中的URL:“https://www.example.net/”是:"ttps://www.example.net/"! 如果我在电子邮件中输入双 'h': "hhttps://www.example.net/" 将是正确的:“https://www.example.net/”.

有什么问题?

P.s。 Link 甚至不适用于图像和电子邮件中发送的所有 link。

尽量使用双引号,转义属于邮件正文的:

$message = "<a href=\"https://www.example.net/path/?Verify=". $IDVer ."\"> here</a>";