To send an email in PHP, you can use the mail() function. Here's how you can do it:
main.php446 chars18 lines
In the code above, you provide the recipient's email address in the $to variable, the subject of the email in the $subject variable, and the actual message in the $message variable.
You can also add additional headers to the $headers variable, such as the "From" email address, "Reply-To" email address, and carbon copy (CC) or blind carbon copy (BCC) addresses.
The mail() function then sends the email. It returns true if the email is sent successfully and false otherwise.
Note that the mail() function relies on the server's configuration for sending emails, so make sure your server is properly configured to send emails. Additionally, this may not work on all hosting environments, as some have restrictions on sending emails.
gistlibby LogSnag