How to add button in mail php

To add a button in a PHP email, you can use HTML and CSS to create the button, and then use PHP to insert the button into the email body. Here's an example:

HTML and CSS:

<style>
 .button {
    background-color: #4CAF50;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }

 .button:hover {
    background-color: #3e8e41;
  }
</style>
<button class="button">Send Email</button>

PHP:

<?php
  // Your email content
  $emailBody = '<p>Hello, this is an email with a button!</p>';
  $emailBody.= '<button class="button">Send Email</button>';

  // Set the email headers
  $headers = 'MIME-Version: 1.0'. "\r\n";
  $headers.= 'Content-type: text/html; charset=UTF-8'. "\r\n";

  // Set the email subject and from address
  $subject = 'Test Email with Button';
  $from = '[email protected]';

  // Set the email recipient
  $to = '[email protected]';

  // Send the email
  mail($to, $subject, $emailBody, $headers);
?>

In this example, we create a simple HTML button with a green background and white text. We then use PHP to insert the button into the email body using the $emailBody variable.

We also set the email headers, subject, from address, and recipient using PHP. Finally, we use the mail() function to send the email.

Note: This is a basic example, and you should consider security and spam filtering when sending emails programmatically. You may also want to use a more advanced email library or service to handle email sending.

Also, keep in mind that some email clients may not render HTML buttons correctly, so it's a good idea to test your email in different clients to ensure it looks and works as expected.