This is Himanshu Kumar ,follow me on Instagram and be the part of HemuVirus . Also subscribe the website for getting new new hacking and coding tricks. Today i am back with a new new hack . In this digital era we all are using android phones which plays a very important role in our daily life from the starting of the to end of the day. But these android phones are also most dangerous for us . this trick is very useful when you give your mobile phone to someone and after that you want to check what he did in your phone .
This trick is all about checking the history of your android phone . you can see all the usage of your android phone with how much time you spend on that app. It is a very simple trick we don’t need to install any other app for this trick. it is totally inbuilt in all android phones. so you can easily access it without doing any changes in your android phone . This trick helps you to check the app you used and how much time you spend .
I am back with a new new topic, which is very user full for a WEB DEVELOPER , Yes Sending mail with the help of PHP MAILER(SMTP) and Mail Function in PHP is the most use full part while developing a website .This topic helps you to send mails to users while using contact us form or while a user registered in your website a automatic mail is send to that user after registration.
PHP is the most popular language for Web Development .When i used PHP mailer to send mail first time it created too many troubles so i thought that nobody should see this kind of trouble from now on. In this tutorial i will show you how we can send mail using Mail function and PHP Mailer function . if you want to know something more or interesting or want to tell me to create new post on any other topic so kindly follow me on Instagram my user id is –hemu_virus.
Now lets start the tutorial-
SEND MAIL USING MAIL FUNCTION
Step 1 – Copy the given code in your mail file and save it on server .
Step 2 – Change the given from address to your email address . and to address to recipient email address.
Step 3 – Open the page with live URL . check recipient email id a mail is received.
<?php
$to = 'mr.hemu22@gmail.com'; // mail id of user to which you want to send mail
$subject = "hemuvirus mailing tutorial"; // subject of mail
$txt = "Dear User,\nThis is the demo of mail function in php. Thank You!"; // Message you want to send
$headers = "From: hemuvirus@gmail.com";//Mail id from which you want to send mail
if(mail($to,$subject,$txt,$headers)){
echo "Mail Send";
} else{
echo "Mail Not Send";
}
}
?>
Output –
Mail Function
SEND MAIL USING PHP MAILER FUNCTION
Step 1 – For using PHP Mailer – 5.2 stable version we need to first Download – PHP Mailer for downloading Click Here .
Step 2 – Now extract the zip file and save it to server.
Step 3 -Now in the same directory create a file and paste the given code .
Step 4 – Now open the Page with live URL and check the recipient email id a mail is received .
Source Code –
<?php
require "PHPMailer/PHPMailerAutoload.php";
function smtpmailer($to, $from, $from_name, $subject, $body)
{
$mail = new PHPMailer();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = 'mail.gmail.com';
$mail->Port = 587;
$mail->Username = 'hemuvirus@gmail.com'; // your email id
$mail->Password = '********'; //your email password
$mail->SMTPDebug = 3; // error debugger
$mail->IsHTML(true);
$mail->From="hemuvirus@gmail.com";
$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 ="Email not sent";
return $error;
}
else
{
$error = "Email sent.";
return $error;
}
}
$to = 'mr.hemu22@gmail.com'; // recipient mail address
$from = 'hemuvirus@gmail.com'; // your mail address
$name = 'hemuvirus'; //name of sender
$subj = 'hemuvirus tutorial'; //subject of mail
$msg = 'Hey welcome to hemuvirus tutorial'; //message which you want to send
$error=smtpmailer($to,$from, $name ,$subj, $msg);
?>
<html>
<head>
<title>HemuVirus</title>
</head>
<body>
<center><?php echo $error; ?></center>
</body>
</html>
Output –
And don’t be afraid about the yellow color warning message it is due to the wrong email address so kindly use correct email address if you don’t want these warnings in your mail.