How to insert php code into an email?

Code below. This is a simple mail sending script. there is a line “here is your secret code”. I want to insert after these words rand(30, 100); it should generate random numbers. After the letter will be sent and the recipient will see these numbers. Tell me how to do it? The problem is that I can’t insert php code into the text of the letter. How to insert php code between $message =”; ?

$to  = $mail;
$subject = " ";
$message ='
 <html>
     <head>
         <title>,    </title>
     </head>
     <body>
         <p>   :  </p>
          <p>   .</p>
     </body>
 </html>';
$headers  = "Content-type: text/html; charset=windows-1251 \r\n";
mail($to, $subject, $message, $headers);

Answer 1, authority 100%

$code=rand(30, 100);
$message =' <html> <head> <title>,    </title> </head> <body> <p>   : '.$code.'</p>'

Answer 2

$oldMessage ='<html>
             <head>
               <title>,    </title>
             </head>
             <body>
               <p>   :  </p>
               <p>   .</p>
             </body>
           </html>';
$messageParts = explode('<p>   </p>',$oldMessage);
$delimiter ='<p>   .</p>';
$newMessage = $messageParts[0] . rand(30, 100) . $delimiter . $messageParts[1]