Email Function
Sending Emails
PHP has a built-in function called mail()
that allows you to send emails directly from a script.
Here's a basic example:
In the above example, the mail()
function takes four arguments: the recipient's email, the email subject, the email body text, and additional headers like 'From' or 'CC'.
Here's a more advanced example that sends an HTML email:
In this example, the Content-type
header is set to text/html
to indicate that the email content should be interpreted as HTML.
Please note that the PHP mail()
function requires your server to be configured to send mail. This usually involves setting up an SMTP server, and the configuration details can vary depending on your hosting environment.
Last updated