Our first step in sending email is locating php.ini file in htdocs folder and then editing.
PHP must be configured correctly in the php.ini file with the details of how your system sends email. Open php.ini file available in /etc/ directory and find the section headed [mail function].We try and find the WORD SMTP and a description shall be made there in place of the description write your "ip" address
in place of localhost.This will solve the purpose.(press Ctrl+F) and write SMTP and find next and so on.
Windows users should ensure that two directives are supplied. The first is called SMTP that defines your email server address. The second is called sendmail_from which defines your own email address.
SYNTAX:-
Here is the description for each parameters.
Parameter Description
to Required. Specifies the receiver / receivers of the email
subject Required. Specifies the subject of the email. 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.
Below is a simple program for sending email:-
<html>
<head>
<title>Sending email using PHP</title>
</head>
<body>
<?php
$to = "abc@domainName.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:pqr@domainName.com \r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
</body>
</html>
PHP must be configured correctly in the php.ini file with the details of how your system sends email. Open php.ini file available in /etc/ directory and find the section headed [mail function].We try and find the WORD SMTP and a description shall be made there in place of the description write your "ip" address
in place of localhost.This will solve the purpose.(press Ctrl+F) and write SMTP and find next and so on.
Windows users should ensure that two directives are supplied. The first is called SMTP that defines your email server address. The second is called sendmail_from which defines your own email address.
SYNTAX:-
Here is the description for each parameters.
Parameter Description
to Required. Specifies the receiver / receivers of the email
subject Required. Specifies the subject of the email. 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.
Below is a simple program for sending email:-
<html>
<head>
<title>Sending email using PHP</title>
</head>
<body>
<?php
$to = "abc@domainName.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:pqr@domainName.com \r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
</body>
</html>
No comments:
Post a Comment