How To Send Plain Text Mail Using PHP Mail Function
How To Send Plain Text Mail Using PHP Mail Function
PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters.
Here is the description for each parameters.
Sr.No | Parameter & Description |
---|---|
1 | to Required. Specifies the receiver / receivers of the email |
2 | subject Required. Specifies the subject of the email. This parameter cannot contain any newline characters |
3 | message Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters |
4 | headers Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n) |
5 | parameters Optional. Specifies an additional parameter to the send mail program |
As soon as the mail function is called PHP will attempt to send the email then it will return true if successful or false if it is failed.
Multiple recipients can be specified as the first argument to the mail() function in a comma separated list.
[php]
<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";
mail($to,$subject,$txt,$headers);
?>
[/php]
Comments
Post a Comment