简体   繁体   中英

Create Clickable verification link PHP mail

For email verification, I am creating a hash for each user and then sending a verification email to the user.The message body is given below.

 $message_body = '
        Hello '.$first_name.',

        Thank you for signing up!

        Please click this link to activate your account:

        http://www.alphaktu.co.in/verify.php?email='.$email.'&hash='.$hash  ;

But I want to convert the verification link to a clickable link.

For starters, you might want to use HTML links within your email body, something like this:

  $message_body = '

    Hello '.$first_name.',

    Thank you for signing up!
    Please click this link to activate your account:

    <a href="http://www.alphaktu.co.in/verify.php?email='.$email.'&hash='.$hash.'"> 
         Verification Link 
    </a>'  ;

Secondly, for this to actually work, you need to use the HTML MIME type when setting headers for your email. If you haven't, it will look something like this:

// Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

This basically tells the browser to interpret the HTML code with your message body as actual HTML, and not plain text.

For email verification, I am creating a hash for each user and then sending a verification email to the user.The message body is given below.

 $message_body = '
        Hello '.$first_name.',

        Thank you for signing up!

        Please click this link to activate your account:

        http://www.alphaktu.co.in/verify.php?email='.$email.'&hash='.$hash  ;

But I want to convert the verification link to a clickable link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM