How to Hide MailTo Using PHP

When you need to provide an email address on a Web page, one option is to use a mailto link. This is an option that uses HTML to open a user's email program. However, if you do not want to clutter the page with code for mailto links, you can easily remove them. As a replacement for the mailto link, you can use PHP. PHP performs the same function by sending an email header to your Web browser.

Instructions

    • 1

      Click "Start" and type "Notepad" in the search box. Press "Enter" to open the program for a new PHP file.

    • 2

      Type ">php" and press "Enter."

      Type "header ("Location: mailto:someone@example.com");" and press "Enter." Replace "someone@example.com" with an actual email address.

      Type "?>" and press "Enter."

      Type "<html><body>" and press "Enter."

      Type "<h1> Email Sent!<h1>" and press "Enter."

      Type "</body></html>" to complete the code.

    • 3

      Click the "File" drop-down menu, and select the option for "Save." Save the file as email.php or a name that you want to use with the extension PHP. Upload this file to your server.

    • 4

      Click the "File" drop-down again, and select "Open." Navigate to the HTML file that has the mailto links that you want to remove.

    • 5

      Replace any "mailto" links that are on the page with the link to the "email.php" file. Save your Web page, and upload it to the server.

Tips & Warnings

  • When a user clicks the link for email.php, his email program will open with the email address already pre-filled.

Related Searches:

References

Comments

Related Ads

Featured