Php html mail link
A classic combination!
Here's an example of how you can create a PHP script that sends an email with a link using HTML:
index.php
<?php
// Define the email settings
$to = '[email protected]';
$subject = 'Test Email with Link';
$message = '<p>Hello!</p><p><a href="https://example.com">Click here to visit our website</a></p>';
$headers = 'From: [email protected]'. "\r\n".
'Reply-To: [email protected]'. "\r\n".
'Content-Type: text/html; charset=UTF-8';
// Send the email using PHP's mail function
mail($to, $subject, $message, $headers);
// Output a success message
echo 'Email sent successfully!';
?>
In this example, we define the email settings:
$to
: the recipient's email address$subject
: the subject of the email$message
: the email body, which includes an HTML link$headers
: the email headers, including theFrom
andReply-To
addresses, as well as theContent-Type
header set totext/html
We then use PHP's mail
function to send the email. The mail
function takes four arguments: the recipient's email address, the subject, the email body, and the email headers.
Finally, we output a success message to indicate that the email was sent successfully.
Note: Make sure to replace the placeholders ([email protected]
and [email protected]
) with your actual email addresses.
Also, keep in mind that this is a basic example, and you may want to add additional functionality, such as error handling and email validation, depending on your specific use case.