<p>It&#39;s relatively easy to send email from a PHP script running on a web page. You can even specify whether the PHP script should use a local or remote <a href="https://www.lifewire.com/definition-of-smtp-817975" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="1">SMTP</a> server for sending messages.</p><h3>PHP Send Email Example</h3><p>The first part of this function is the recipient, the second specifies the message&#39;s subject, and the third one should contain the body.</p><p>Here&#39;s a simple PHP email example:</p><pre> <code>&lt;?php $to &#61; &#34;recipient&#64;example.com&#34;; $subject &#61; &#34;Hi!&#34;; $body &#61; &#34;Hi,\n\nHow are you?&#34;; if (mail($to, $subject, $body)) { echo(&#34;&lt;p&gt;Email successfully sent!&lt;/p&gt;&#34;); } else { echo(&#34;&lt;p&gt;Email delivery failed…&lt;/p&gt;&#34;); } ?&gt;</code></pre><h3>More PHP Email Options</h3><p>There are a few other things you can do with the <a href="https://www.lifewire.com/php-file-4138559" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="2">PHP file</a>.</p><p>If you want the &#34;From&#34; <a href="https://www.lifewire.com/what-is-an-email-header-1171127" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="3">header</a> line to be included in the PHP script, you just need to <a href="https://www.lifewire.com/how-to-send-email-with-extra-headers-in-php-1171196" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="4">add that extra header line</a>. That guide will show you how to add an extra option in the script that defines a particular &#34;From&#34; email address, much like a regular email interface.</p><p>The <em>mail() </em>function included with stock PHP does not support SMTP authentication. If <em>mail()</em> does not work for you for this or another reason, try the PEAR Mail package, which is much more comprehensive while maintaining, to a large degree, the simplicity and ease of <em>mail()</em> for sending mail from PHP.</p><p>Want to choose which SMTP server the email uses for authentication? This will alter the header information when the recipient receives the email. You can either use the local SMTP server of the machine that&#39;s running the script or <a href="https://www.lifewire.com/how-to-configure-php-remote-smtp-server-for-sending-mail-1171190" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="5">specify a remote SMTP server</a>.</p><p>To make sure users enter an actual email address, you can <a href="https://www.lifewire.com/how-to-validate-email-addresses-in-a-php-script-1171192" data-component="link" data-source="inlineLink" data-type="internalLink" data-ordinal="6">validate the text field</a> to ensure that it contains an email-like structure. </p><p><strong>Tip:</strong> There&#39;s a lot more information on the send mail function of PHP at <a href="http://php.net/manual/en/function.mail.php" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="7">PHP.net</a>.</p><h3>Protecting Your Script From Spammer Exploit</h3><p>If you use the <em>mail()</em> function (in combination with a web form in particular), make sure you check that it&#39;s called from the desired page and protect the form with something like a CAPTCHA.</p><p>You can also <a href="http://www.phpbuilder.com/columns/ian_gilfillan20060412.php3" data-component="link" data-source="inlineLink" data-type="externalLink" data-ordinal="8" rel="nofollow">check for suspicious strings</a> (say, &#34;Bcc:&#34; followed by a number of email addresses).</p>