· 8 years ago · Jun 20, 2018, 04:26 PM
1<form name="contactform" method="post" action="sendMail.php">
2
3<table width="400px">
4
5<tr>
6
7 <td valign="top">
8
9 <label for="first_name">First Name *</label>
10
11 </td>
12
13 <td valign="top">
14
15 <input type="text" name="first_name" maxlength="50" size="30">
16
17 </td>
18
19</tr>
20
21<tr>
22
23 <td valign="top">
24
25 <label for="last_name">Last Name </label>
26
27 </td>
28
29 <td valign="top">
30
31 <input type="text" name="last_name" maxlength="50" size="30">
32
33 </td>
34
35</tr>
36
37<tr>
38
39 <td valign="top">
40
41 <label for="email">Email *</label>
42
43 </td>
44
45 <td valign="top">
46
47 <input type="text" name="email" maxlength="80" size="30">
48
49 </td>
50
51</tr>
52
53<tr>
54
55 <td valign="top">
56
57 <label for="telephone">Phone</label>
58
59 </td>
60
61 <td valign="top">
62
63 <input type="text" name="telephone" maxlength="30" size="30">
64
65 </td>
66
67</tr>
68
69<tr>
70
71 <td valign="top">
72
73 <label for="comments">Comments *</label>
74
75 </td>
76
77 <td valign="top">
78
79 <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
80
81 </td>
82
83</tr>
84
85<tr>
86
87 <td colspan="2" style="text-align:center">
88
89 <input type="submit" value="SUBMIT">
90
91 </td>
92
93</tr>
94
95</table>
96
97</form>
98
99<?php
100
101require 'PHPMailer-master/PHPMailerAutoload.php';
102
103$mail = new PHPMailer;
104
105$mail->isSMTP();
106$mail->Host = 'smtp.gmail.com';
107$mail->SMTPAuth = true;
108$mail->Username = 'myname@gmail.com';
109$mail->Password = 'H********';
110$mail->SMTPSecure = 'tls';
111$mail->Port = 587;
112$mail->SMTPDebug = 1;
113
114$mail->From = 'myname@gmail.com';
115$mail->FromName = 'TEST';
116$mail->addAddress('myname@domain.com');
117
118$errors = '';
119
120if(empty($_POST['name']) ||
121 empty($_POST['email']) ||
122 empty($_POST['phone']) ||
123 empty($_POST['message']))
124{
125 $errors .= "n Error: all fields are required";
126}
127$name = $_POST['name'];
128$email_address = $_POST['email'];
129$phone = $_POST['phone'];
130$message = $_POST['message'];
131if (!preg_match(
132"/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i",
133$email_address))
134{
135 $errors .= "n Error: Invalid email address";
136}
137
138if( empty($errors))
139{
140$to = $myemail;
141
142
143
144mail($to, $subject, $message, $headers);
145
146$email_subject = "Request Additional Information: $name";
147$email_body = "You have received a new request for additional information. ".
148" Here are the details:n Name: $name n ".
149"Email: $email_addressn Phone: $phonen Message: n $message";
150$headers = "From: $myemailn";
151$headers .= "Reply-To: $email_address";
152mail($to,$email_subject,$email_body,$headers);
153//redirect to the 'thank you' page
154header('Location: contact-form-thank-you.html');
155}
156
157
158?>
159
160<form name="contactform" method="post" action="sendMail.php">
161
162<table width="400px">
163
164<tr>
165
166 <td valign="top">
167
168 <label for="first_name">First Name *</label>
169
170 </td>
171
172 <td valign="top">
173
174 <input type="text" name="first_name" maxlength="50" size="30">
175
176 </td>
177
178</tr>
179
180<tr>
181
182 <td valign="top">
183
184 <label for="last_name">Last Name </label>
185
186 </td>
187
188 <td valign="top">
189
190 <input type="text" name="last_name" maxlength="50" size="30">
191
192 </td>
193
194</tr>
195
196<tr>
197
198 <td valign="top">
199
200 <label for="email">Email *</label>
201
202 </td>
203
204 <td valign="top">
205
206 <input type="email" name="email" maxlength="80" size="30">
207
208 </td>
209
210</tr>
211
212<tr>
213
214 <td valign="top">
215
216 <label for="telephone">Phone</label>
217
218 </td>
219
220 <td valign="top">
221
222 <input type="text" name="telephone" maxlength="30" size="30">
223
224 </td>
225
226</tr>
227
228<tr>
229
230 <td valign="top">
231
232 <label for="comments">Comments *</label>
233
234 </td>
235
236 <td valign="top">
237
238 <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
239
240 </td>
241
242</tr>
243
244<tr>
245
246 <td colspan="2" style="text-align:center">
247
248 <input type="submit" value="SUBMIT">
249
250 </td>
251
252</tr>
253
254</table>
255
256</form>
257
258<?php
259$first_name="First Name : ".$_POST['first_name']."<br>";
260$last_name="Last Name :". $_POST['last_name']. "<br>";
261$your_email="Your Email :".$_POST['email']. "<br>";
262$telephone="Your Telephone :".$_POST['telephone']. "<br>";
263$your_message="Your Comments :".$_POST['comments']. "<br>";
264$message = "
265 n $first_name n
266 n $last_name n
267 n $your_email n
268 n $telephone n
269 n $your_message n
270";
271echo $message;
272include "PHPMailer_5.2.4/class.phpmailer.php";
273
274
275$mail = new PHPMailer;
276 $mail->isSMTP();
277 $mail->Host = 'smtp.gmail.com';
278
279 $mail->SMTPAuth = true;
280 $mail->Username = '***@gmail.com';
281 $mail->Password = 'gmailpassword';
282 $mail->SMTPSecure = 'tls';
283 $mail->Port = 587;
284 $mail->setFrom('someaddress@example.com', 'Mailer');
285 $mail->addAddress($your_email, 'Name');
286 $mail->addAttachment('fileaddress');
287 $mail->isHTML(true);
288 $mail->Subject = 'Here is the subject';
289 $mail->Body = $message;
290 $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
291
292 if(!$mail->send()) {
293 echo 'Message could not be sent.';
294 echo 'Mailer Error: ' . $mail->ErrorInfo;
295 } else {
296 echo 'Message has been sent';
297 }
298?>
299
300<?php
301
302$AnalystName ="Analyst Name : ".$_POST['AnalystName']. "<br>";
303$action_JIRA =" Was JIRA checked? ".$_POST['action_JIRA']. "<br>";
304$Jira_Findings ="Notable JIRA Findings :".$_POST['Jira_Findings']. "<br>";
305$action_Redlock ="Was Redlock checked? ".$_POST['action_Redlock']. "<br>";
306$Redlock_Findings ="Notable Redlock Findings :".$_POST['Redlock_Findings']. "<br>";
307$action_tenableSC ="Was Tenable Security Center Checked? ".$_POST['action_tenableSC']. "<br>";
308$Tenable_SecCenter_Findings ="Notable Tenable Security Center Findings :".$_POST['Tenable_SecCenter_Findings']. "<br>";
309$action_tenableCloud ="Was Tenable Cloud Checked? ".$_POST['action_tenableCloud']. "<br>";
310$Tenable_CloudConsole_Findings ="Notable Tenable Cloud Findings :".$_POST['Tenable_CloudConsole_Findings']. "<br>";
311
312$message = "
313 n $AnalystName n
314 n $action_JIRA n
315 n $Jira_Findings n
316 n $action_Redlock n
317 n $Redlock_Findings n
318 n $action_tenableSC n
319 n $Tenable_SecCenter_Findings n
320 n $action_tenableCloud n
321 n $Tenable_CloudConsole_Findings n
322";
323echo $message;
324include "phpMailer/class.PHPmailer.php";
325
326
327$mail = new PHPMailer;
328 $mail->isSMTP();
329 $mail->Host = 'smtp.gmail.com';
330 $mail->SMTPAuth = true;
331 $mail->Username = '****blahblah@gmail.com';
332 $mail->Password = '***';
333 $mail->SMTPSecure = 'tls';
334 $mail->Port = 587;
335 $mail->setFrom('****blahblah@gmail.com', 'Mailer');
336 $mail->addAddress($your_email, 'Name');
337 $mail->addAttachment('fileaddress');
338 $mail->isHTML(true);
339 $mail->Subject = 'InfoSec Daily Analyst Report';
340 $mail->Body = $message;
341 $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
342
343 if(!$mail->send()) {
344 echo 'Message could not be sent.';
345 echo 'Mailer Error: ' . $mail->ErrorInfo;
346 } else {
347 echo 'Message has been sent';
348 }
349?>