Keep in mind that although additional headers are optional, it’s essential to mention the From header when sending mail. Alternatively, the message below will be displayed. The message above will appear when the script is executed successfully. This line is used to execute the function and check whether it has run successfully. if (mail ($to,$subject,$message,$headers)) This line is commonly used to add additional headers, such as From, Reply-To, and Cc – these extra headers should be separated with a CRLF ( \r\n). Here, input the body of your email message. $subject = "Checking PHP mail" Įnter the subject line for the email here. If you want to deliver the message to multiple recipients, separate their email addresses with commas. $to = recipient’s email address goes here. Thus, it’s better to use one with your domain name to execute the script successfully.
![php maker user guide php maker user guide](https://phpmaker.dev/doc/images/quick2.png)
Most hosting providers forbid adding random email addresses here, as they can be used for spoofing. $from = line should contain the sender’s email address. The first two lines above enable error reporting to tell you if the PHP script has failed to execute. To help you understand the PHP mail() function, we’ll go over the components of the PHP script we used in the previous section: ini_set( 'display_errors', 1 )
#PHP MAKER USER GUIDE CODE#
You can use the basic PHP code below, but make sure to change its parameters accordingly. Double click on testmail.php to edit it.Name this new file testmail.php, then hit Create. Double click on the public_html folder and select the New File icon at the top bar.From hPanel, navigate to Files -> File Manager to access the Hostinger File Manager.Hostinger users can toggle this function by accessing the hPanel and navigating to Emails -> Mail Service Control.Īfter making sure that Sendmail is active, we’ll create a PHP mail script file and place it in the public_html directory.
![php maker user guide php maker user guide](https://phpmaker.dev/doc/images/quick1.png)
However, you need to make sure that your hosting provider allows you to manually manage the Sendmail service option. If you use a hosting server, Sendmail is usually already configured. To use the PHP send mail feature, users hosting their PHP application or site on a local server will need to configure a Sendmail program by changing the php.ini file in their PHP installation folder. The first method to send emails directly from a PHP script is by using the built-in mail() function.
#PHP MAKER USER GUIDE HOW TO#
How to Send Emails Using PHP mail() Function