How can I send a link in an email using PHP?
To send a link in an email using PHP, you can use the `mail()` function to send an email with HTML content that includes the link. You can create an HTML email body with the link included and set the appropriate headers to ensure the email is sent as HTML. Make sure to properly format the link within the HTML body to ensure it is clickable.
$to = "recipient@example.com";
$subject = "Check out this link!";
$link = "https://www.example.com";
$message = "<html><body><p>Click <a href='$link'>here</a> to view the link.</p></body></html>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: sender@example.com" . "\r\n";
mail($to, $subject, $message, $headers);
Related questions
-
PHP4 PHP5 constructors
-
foreach loop string value array
-
validation sanitization htmlspecialchars