It’s as follows :
Page 1:config.php
class mymailer
{
function mysendmail($from,$to,$subject='sub',$body='msg',$content_type='text/html',$auth=true,$host=MAIL_HOST,$username=MAIL_USERNAME,$password=MAIL_PASSWORD)
{
require_once "Mail.php"; //you should install PEAR::Mail module in your server
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-type'=>$content_type
);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => $auth,
'username' => $username,
'password' => $password)
);
$mail = $smtp->send($to, $headers,$body);
if (PEAR::isError($mail))
{
//return $mail->getMessage();
return 'F';
}
else
{
return 'S';
}
}
}
You can call this class as :
Page 2: mail_sending_page.php
require_once "config.php";
$from="frommail@company.com";
$to="tomail@example.com";
$subject="My Mail Subject";
$body="This is the body of this mail. Your content goes here.";
$mails=new mymailer;
$mails->mysendmail($from,$to,$subject,$body);
Like this:
Like Loading...
You must be logged in to post a comment.