How to install PHPMailer

phpmailer send email

How to install PHPMailer

Do you need to send emails from your PHP application?
This complete guide (updated in 2019) will teach you how to setup and run the most used PHP email library: PHPMailer.

<?php
require "PHPMailer/PHPMailerAutoload.php";
function smtpmailer($to, $from, $from_name, $subject, $body)
    {
        $body = "name : ".$_POST['name']."<br>";
        $body .= "email : ".$_POST['email']."<br>";
        $body .= "phone : ".$_POST['phone']."<br>";
        $body .= "city : ".$_POST['city']."<br>";
        
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth = true; 
 
        $mail->SMTPSecure = 'ssl'; 
        $mail->Host = 'ENTER SMTP SERVER HOST NAME';
        $mail->Port = port number;  
        $mail->Username = 'Enter your email id';
        $mail->Password = 'enter your password';   
   

   
        $mail->IsHTML(true);
        $mail->From="Enter Your Email id";
        $mail->FromName=$from_name;
        $mail->Sender=$from;
        $mail->AddReplyTo($from, $from_name);
        $mail->Subject = $subject;
        $mail->Body = $body;
        $mail->AddAddress($to);
        if(!$mail->Send())
        {
            $error ="Please try Later, Error Occured while Processing...";
            return $error; 
        }
        else 
        {
            $error = "Thanks You !! Your email is sent.";  
            return $error;
        }
    }
    
    $to   = 'enter your email id';
    $from = 'enter your email id';
    $name = 'your company name or your name';
    $subj = 'Enter your Subject';
    
    $error=smtpmailer($to,$from, $name ,$subj, $msg);
 
   
    
  
  echo "<script>";
    echo "alert('Your Req successfully send.');";
    echo "window.location='Enter your redirect page name';";
    echo "</script>";
    $msg="Your Request accept";
	//header('Location: Enter your Header location');
?>

What's Your Reaction?

like
4
dislike
0
love
0
funny
0
angry
0
sad
0
wow
0