This post explains you how to send mail using SMTP credentials.It’s simple just few lines of configuration changes.
index.php
Contains PHP code. You have to modify email, name and message
$to="user@gmail.com";
$fn="Fisrt Name";
$ln="Last Name";
$name=$fn.' '.$ln;
$from="support@website.com";
$subject = "Welcome to Website";
$message = "Dear $name,
Your Welcome Message.
Thanks
www.website.com
";
include('smtpwork.php');
$fn="Fisrt Name";
$ln="Last Name";
$name=$fn.' '.$ln;
$from="support@website.com";
$subject = "Welcome to Website";
$message = "Dear $name,
Your Welcome Message.
Thanks
www.website.com
";
include('smtpwork.php');
smtpwork.php
SMTP configuration file you have to modify host, port and credentials.
<?php
require("smtp.php");
require("sasl.php"); //SASL authentication
$from="support@yourwebsite.com";
$smtp=new smtp_class;
$smtp->host_name="www.website.com"; // Or IP address
$smtp->host_port=25;
$smtp->ssl=0;
$smtp->start_tls=0;
$smtp->localhost="localhost";
$smtp->direct_delivery=0;
$smtp->timeout=10;
$smtp->data_timeout=0;
$smtp->debug=1;
$smtp->html_debug=1;
$smtp->pop3_auth_host="";
$smtp->user="support@website.com"; // SMTP Username
$smtp->realm="";
$smtp->password="password"; // SMTP Password
$smtp->workstation="";
$smtp->authentication_mechanism="";
if($smtp->SendMessage(
$from,
array(
$to
),
array(
"From: $from",
"To: $to",
"Subject: $subject",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
),
"$message"))
{
echo "Message sent to $to OK.";
}
else
echo "Cound not seend the message to $to.\nError: ".$smtp->error;
?>
require("smtp.php");
require("sasl.php"); //SASL authentication
$from="support@yourwebsite.com";
$smtp=new smtp_class;
$smtp->host_name="www.website.com"; // Or IP address
$smtp->host_port=25;
$smtp->ssl=0;
$smtp->start_tls=0;
$smtp->localhost="localhost";
$smtp->direct_delivery=0;
$smtp->timeout=10;
$smtp->data_timeout=0;
$smtp->debug=1;
$smtp->html_debug=1;
$smtp->pop3_auth_host="";
$smtp->user="support@website.com"; // SMTP Username
$smtp->realm="";
$smtp->password="password"; // SMTP Password
$smtp->workstation="";
$smtp->authentication_mechanism="";
if($smtp->SendMessage(
$from,
array(
$to
),
array(
"From: $from",
"To: $to",
"Subject: $subject",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
),
"$message"))
{
echo "Message sent to $to OK.";
}
else
echo "Cound not seend the message to $to.\nError: ".$smtp->error;
?>
Parthiv Patel
Bhaishri Info Solution
Sr. PHP Developer
Limdi Chowk, AT PO. Nar, Di. Anand
Nar, Gujarat
388150
India
pparthiv2412@gmail.com
7383343029
DOB: 12/24/1986
No comments:
Post a Comment