More Related Content
Similar to Php mail program (20)
More from pyingkodi maran (9)
Php mail program
- 1. TO CONFIGURE RUNTIME PHP AND EMAIL SERVICE
<?php
//Follow the below steps
//login into your gmail then copy paste this url
//https://www.google.com/settings/security/lesssecureapps
// enable it.
require 'PHPMailer/PHPMailerAutoload.php';
if(isset($_POST['submit'])){
$mail = new PHPMailer;
$name = $_POST['name'];
$femail = $_POST['femail'];
$toemail = $_POST['email'];
$pass = $_POST['pwd'];
//$bccemail = $_POST['bccemail'];
$subject = $_POST['subject'];
$bodycontent = $_POST['message'];
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'loganyavairam@gmail.com'; // SMTP username
$mail->Password = 'vrslfamily'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom($femail, $name);
$mail->addReplyTo($femail, $name);
$mail->addAddress($toemail); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $bodycontent;
$mail->AddAttachment($_FILES['image']['tmp_name'], $_FILES['image']['name']);
if(!$mail->send()) {
echo 'Message could not be sent.';
echo '<font color = "Black">Mailer Error: ' . $mail->ErrorInfo.'</font>';
} else {
echo '<font color = "Blue">Message has been sent</font>';
}
}
?>
- 2. <html>
<body>
<form action="" method="POST" enctype='multipart/form-data'>
<table>
<tr>
<td> Name : </td>
<td><input type="text" id="name" name="name" placeholder='User Name'/>
<div id="invalid-name"></div></td></tr>
<tr>
<td> From E-mail: </td>
<td><input type="email" id="femail" name="femail" placeholder='From E-mail'/>
<div id="invalid-name"></div>
</td><tr>
<td> To E-mail : </td>
<td><input type="email" id="email" name="email" placeholder='E-Mail'/>
<div id="invalid-email"></div>
</td></tr>
<td> Subject : </td>
<td><input type="text" id="subject" name="subject" placeholder='Subject'/>
<div id="invalid-femail"></div>
</td>
</tr>
<tr>
<td> Image : </td>
<td><input type="file" id="image" name="image" placeholder='Image' accept="image/*"> <div
id="invalid-image"></div></td>
</tr>
<tr>
<td> Message : </td>
<td><textarea cols="27" rows="5" id="message" name="message" placeholder='Message'
value=''></textarea><div id="invalid-message"></td>
</tr>
<tr>
<td colspan="2"> <input type="submit" value="Send Mail!" id='submit_btn'
name="submit"/></td>
</tr>
<table>
</form>
</body>
</html>