How can I send an email using PHP
PHP mail() Function
PHP has an internal function called mail(), which can support few parameters as follows
Syntax
mail(to,subject,message,headers,parameters);
Parameter Details
to -> Required. Specifies the receiver / receivers of the email
subject -> Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters
message -> Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters.
headers -> Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n).
parameters -> Optional. Specifies an additional parameter to the sendmail program (the one defined in the sendmail_path configuration setting). (i.e. this can be used to set the envelope sender address when using sendmail with the -f sendmail option)
Send an email Example
<?php
$to = "devesh@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: info@example.com" . "\r\n" .
"CC: hari@example.com";
mail($to,$subject,$txt,$headers);
?>
Comments (0)
Post a Comment
Cancel