Hi, friends. I own space in Hostgator and recently I have written a PHP script to send emails programmatically.
PHP has a function called mail() which allow you to send email directly from the script.
Syntactically this function looks like mail(to, subject, message, headers, parameters). here headers and parameters are optional.
PHP has a function called mail() which allow you to send email directly from the script.
Syntactically this function looks like mail(to, subject, message, headers, parameters). here headers and parameters are optional.
- to - This parameter takes a string value that is nothing but the email id to which you are sending an email.
- subject - Specifies the subject of the email
- message - This parameter takes a string value that is the message itself.
- headers - Specifies addition information like From, Cc, and Bcc.
- parameters -Specifies an additional parameter to Sendmail program. This can be used to set the envelope sender address when using Sendmail with -f option.
script:
<?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);
?>
$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);
?>
If you are using Hostgator's server space then you have to place this program file inside the root directory of your domain.