How to Create an Email Parameter in PHP
- 1). Create a new PHP file. Any text editor can be used to create the file.
- 2). Type "<?php" at the beginning of the document to instruct the server that all following code is to be compiled as PHP. Note that the quotations marks are not included in the actual program code.
- 3). Type "mail(" on a new line. Inside this parenthesis will be all the email parameters of this PHP command. Note that the quotations marks are not included in the actual program code.
- 4). Type the email address of the recipient inside the parenthesis, and then type a comma.
- 5). Type the subject line for the email next, and place this in double quotes. Type a comma after this subject has been entered. Be sure the comma is located after the final double quote.
- 6). Type the email message, and place this in double quotes. The entire message is a single parameter located inside the "mail" parenthesis. If the message has instead been previously declared and assigned to a PHP variable, you may simply type the name of that variable here and PHP will substitute its contents for the email message.
- 7). Type a comma if you wish to add other email parameters to this PHP command. Email headers, including the "From" or "Cc" fields, are optional. However, you can add them in double quotes, such as "From: me@me.com". If you do not include a "From," the server will automatically add its generic server name as the sending email address.
- 8). Add a closing parenthesis and a semicolon to end the command. The final PHP statement with all email parameters may read: 'mail(my_friend@example.com, "This is the subject.","This is the message!","From:me@me.com");'. Note that single quotes are not included in the type code.
- 9). Type "?>" at the end of the file to close the PHP code. Note that the quotations marks are not included in the actual program code.
- 10
Execute the PHP file. Once it is run, an email will be automatically generated. You can run the file by visiting the URL of the PHP file on the Web server where it is hosted.
Source...