-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
391 lines (349 loc) · 15.4 KB
/
mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<?php
session_start();
include('connection.php');
if(!isset($_SESSION["user"])){
echo 'Please login to view this page!';
header('Location: login_view.php');
die();
}
else {
extract($_POST);
if (isset($_POST['submit']))
{
if ( $email =="" || $subject =="" || $name =="" || $message =="")
{
$error_message="Fill all the fileds first";
}
else
{
require_once 'vendor/autoload.php';
$mail = new PHPMailer\PHPMailer\PHPMailer;
//Enable SMTP debug mode
$mail->SMTPDebug = 0;
//set PHPMailer to use SMTP
$mail->isSMTP();
//set host name
$mail->Host = "SMTP hostname";
// set this true if SMTP host requires authentication to send mail
$mail->SMTPAuth = true;
//Provide username & password
$mail->Username = "user_name";
$mail->Password = "password";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;// Enter port number
$mail->ClearReplyTos();
$mail->addReplyTo("your own domain email id", $_POST['name']);
$mail->SetFrom("your own domain email id", $_POST['name']);
/*
$mail->From = "your own domain email id";
$mail->FromName = " ".$_POST['name']." ";
======> instead of two lines i Used one line =>>>> $mail->SetFrom("your own domain email id", $_POST['name']);
*/
$mail->addAddress($_POST["email"]);
/*
$file = "attachment/".basename($_FILES['attachment']['name']);
move_uploaded_file($_FILES['attachment']['tmp_name'], $file);
$mail->addAttachment("attachment/".basename($_FILES['attachment']['name']));
*/
if(isset($_FILES['file'])):
//$validextensions = array("jpeg", "jpg", "png" , "pdf" );
foreach($_FILES['file']['name'] as $k => $ar):
// $temporary = explode(".", $_FILES['file']['name'][$k]);
// $file_extension = end($temporary);
// if ((($_FILES['file']['type'][$k] == "image/png") || ($_FILES['file']['type'][$k] == "image/jpg") || ($_FILES['file']['type'][$k] == "image/jpeg") || ($_FILES['file']['type'][$k] == "application/pdf")
// ) && ($_FILES['file']['size'][$k] < 10000000)//Approx. 1000kb files can be uploaded.
// && in_array($file_extension, $validextensions))
{
/*if ($_FILES['file']['error'][$k] > 0)
{
echo "Return Code: " . $_FILES['file']['error'][$k] . "<br/><br/>";
}
else
{
if (file_exists("attachment/" . $_FILES['file']['name'][$k])) {
echo $_FILES['file']['name'][$k] . " <span id='invalid'><b>already exists.</b></span> ";
}
else
{*/
$sourcePath = $_FILES['file']['tmp_name'][$k]; // Storing source path of the file in a variable
$targetPath = "attachment/".$_FILES['file']['name'][$k]; // Target path where file is to be stored
move_uploaded_file($sourcePath,$targetPath) ; // Moving Uploaded file
$mail->addAttachment("attachment/".$_FILES['file']['name'][$k]);
/*}
}*/
// }
// else
// {
// $error_message= "Invalid file Size or Type ";
}
endforeach;
endif;
$mail->isHTML(true);
$mail->Subject =" ".$_POST['subject']." ";
$body = "<html>
<head> </head>
<body> ".$_POST['message']." <br>
</body>
</html>";
$body .= '......<br>
<table id="zs-output-sig" style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse; width: 550px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828;"><strong style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; color: #FF0000; display: inline;">Thanks & Regards,</strong></td>
</tr>
<tr>
<td style="border-collapse: collapse; padding-bottom: 7px; height: 7px;"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="92">
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border-collapse: collapse; line-height: 0px;"><img src="https://avatars1.githubusercontent.com/u/44359568?s=460&v=4/-/resize/105x120/img.png" width="105" height="120" border="0" /></td>
</tr>
</tbody>
</table>
</td>
<td style="border-collapse: collapse; padding-right: 7px; width: 7px;" width="7"> </td>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 25.0px; font-style: normal; line-height: 32px; font-weight: normal; color: #282828;"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 30.0px; font-style: normal; line-height: 32px; font-weight: normal; color: #282828; display: inline;">PRADIP KUMAR RAUSHAN</span></td>
</tr>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 21.0px; font-style: normal; line-height: 23px; font-weight: bold; color: #282828;"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 23px; font-weight: bold; color: #282828; display: inline;">CSE - SDM College Of Engineering And Technology.</span></td>
</tr>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828;"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828; display: inline;">( Full Stack Developer ).</span></td>
</tr>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828;"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828; display: inline;"><a style="text-decoration: none;" href="http://pradip.epizy.com">pradip.epizy.com</a></span></td>
</tr>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828;"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 14.0px; font-style: normal; line-height: 16px; font-weight: normal; color: #5e4036; display: inline;">Mobile:</span> <span style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828; display: inline;">+919035867192</span></td>
</tr>
<tr>
<td style="border-collapse: collapse; font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828;"><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #5e4036; display: inline;">Address:</span> <span style="font-family: Calibri, Helvetica, sans-serif; font-size: 15.0px; font-style: normal; line-height: 17px; font-weight: normal; color: #282828; display: inline;">Karnataka,India.</span></td>
</tr>
<tr>
<td style="border-collapse: collapse; padding-bottom: 3px; height: 3px;"> </td>
</tr>
</tbody>
</table>
</td>
<td style="border-collapse: collapse; padding-right: 8px; width: 8px;"> </td>
<td style="border-collapse: collapse; background-color: #000000; width: 3px;"> </td>
<td style="border-collapse: collapse; padding-right: 8px; width: 8px;"> </td>
<td>
<table style="font-family: Arial,Helvetica,sans-serif; line-height: 0px; font-size: 1px; padding: 0px; border-spacing: 0px; margin: 0px; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><a style="font-size: 0px; line-height: 0px;" title="Facebook" href="https://www.facebook.com/pradipkumarraushan" rel="nofollow noopener"><img src="https://gimm.io/assets/social/24/171616/04facebook.gif" alt="facebook" width="24" height="24" border="0" /></a></td>
</tr>
<tr>
<td style="border-collapse: collapse; padding-bottom: 5px; height: 5px;"> </td>
</tr>
<tr>
<td><a style="font-size: 0px; line-height: 0px;" title="Github" href="https://github.com/pradipkumarraushan" rel="nofollow noopener"><img src="https://gimm.io/assets/social/24/000000/04github.gif" alt="github" width="24" height="24" border="0" /></a></td>
</tr>
<tr>
<td style="border-collapse: collapse; padding-bottom: 5px; height: 5px;"> </td>
</tr>
<tr>
<td><a style="font-size: 0px; line-height: 0px;" title="LinkedIn" href="https://www.linkedin.com/in/pradipkumarraushan/" rel="nofollow noopener"><img src="https://gimm.io/assets/social/24/000000/04linkedin.gif" alt="linkedin" width="24" height="24" border="0" /></a></td>
</tr>
<tr>
<td style="border-collapse: collapse; padding-bottom: 5px; height: 5px;"> </td>
</tr>
<tr>
<td><a style="font-size: 0px; line-height: 0px;" title="Email" href="mailto:[email protected]" rel="nofollow"><img src="https://ucarecdn.com/33ed08dc-a3e0-451f-afaf-4091eb842ffb/-/crop/426x280/236,119/-/preview/" alt="https://ucarecdn.com/33ed08dc-a3e0-451f-afaf-4091eb842ffb/-/crop/426x280/236,119/-/preview/" width="26" height="17" border="0" /></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="border-collapse: collapse; padding-bottom: 8px; height: 8px;"> </td>
</tr>
<tr>
<td style="border-collapse: collapse;"> </td>
</tr>
</tbody>
</table>';
$mail->MsgHTML($body);
if(!$mail->send()) {
$error_message = "Mailer Error : ". $mail->ErrorInfo;
} else {
$success_message = "Email Sent Successfully";
}
}
}}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="PRADIP KUMAR RAUSHAN">
<meta name="keywords" content="PRADIP KUMAR RAUSHAN">
<meta name="author" content="PRADIP KUMAR RAUSHAN">
<link href="favicon.png" rel="icon" type="image/png"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="ckeditor_4.8.0_full/ckeditor/ckeditor.js"></script>
</head>
<body onLoad="setInterval('tt()',1000)">
<h1 style="color: black" class="text-center">Compose Email</h1>
<?php if(!empty($success_message)) { ?>
<?php echo '<script language="javascript">';
echo 'alert("'.$success_message.'")';
echo '</script>'; ?>
<?php } ?>
<?php if(!empty($error_message)) { ?>
<?php
echo '<script language="javascript">';
echo 'alert("'.$error_message.'")';
echo '</script>';
?>
<?php } ?>
<table class="table table-dark table-striped col-sm-6 offset-sm-3 text-center " >
<form method="post" enctype="multipart/form-data" class="form-inlin justify-content-center form-group">
<tbody>
<tr>
<td>Time / Date</td>
<td><span class="btn btn-info" style="color:white" id="tar"></span></td>
</tr>
<tr>
<td>To</td>
<td><input type="email" name="email" placeholder="Enter Recipient Email Id" class="form-control"></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="subject" placeholder="Subject" class="form-control"></td>
</tr>
<tr>
<td>Your Name</td>
<td><input type="text" name="name" placeholder="Your Name" class="form-control"></td>
</tr>
<tr>
<td>Message</td>
<td>
<textarea name="message" id="text" placeholder="Write Your Message Here" class="form-control" ></textarea>
<script>CKEDITOR.replace( 'text' );</script>
</td>
</tr>
<tr>
<td>Attachment</td>
<td><input type="file" name="file[]" id="img" class="form-control" multiple="multiple" onchange="validateImage()"></td>
</tr>
<tr>
<td><a href="logout.php"><input type="button" value="Sign out" class="btn-danger"></a></td>
<td><input type="submit" value="Send Mail" name="submit" class="btn-success"></td>
</tr>
</tbody>
</form>
</table>
<script type="text/javascript">
function validateImage() {
var formData = new FormData();
var file = document.getElementById("img").files[0];
formData.append("Filedata", file);
var t = file.type.split('/').pop().toLowerCase();
if (t != "jpeg" && t != "jpg" && t != "png" && t != "gif" && t != "pdf") {
alert('Please select a valid file');
document.getElementById("img").value = '';
return false;
}
if (file.size > 5242880) {
alert('Max Upload size is 5MB only');
document.getElementById("img").value = '';
return false;
}
return true;
}
function tt()
{
var d=new Date();
var t=d.getHours()+":"+ d.getMinutes()+":"+ d.getSeconds()+" / "+ d.toDateString() ;
document.getElementById("tar").innerHTML=t;
}
</script>
<style>
html,
body{
height: 100%;
}
#cover {
background: #222 url('') center center no-repeat;
background-size: cover;
height: 100%;
text-align: center;
display: flex;
align-items: center;
}
#cover-caption {
width: 100%;
}
</style>
</body>
</html>