-
Notifications
You must be signed in to change notification settings - Fork 18
/
send_mail.php
42 lines (32 loc) · 1.5 KB
/
send_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
<?php
global $_POST;
$mail_to = '[email protected]'; //Your email here
// Required fields
$email = isset( $_POST['email'] ) ? strip_tags( trim( $_POST['email'] ) ) : '';
$name = isset( $_POST['name'] ) ? strip_tags( trim( $_POST['name'] ) ) : '';
$text = isset( $_POST['message'] ) ? strip_tags( trim( $_POST['message'] ) ) : '';
// Additional fields
$subject = isset( $_POST['subject'] ) ? strip_tags( trim( $_POST['subject'] ) ) : '';
$permalink = isset( $_POST['permalink'] ) ? strip_tags( trim( $_POST['permalink'] ) ) : '';
$phone = isset( $_POST['phone'] ) ? strip_tags( trim( $_POST['phone'] ) ) : '';
$company = isset( $_POST['company'] ) ? strip_tags( trim( $_POST['company'] ) ) : '';
$mail_subject = $subject != '' ? $subject : 'From Contact form on Our website';
$message = '<h3>You got a Mail from the Company Website:</h3>' . '<br/>';
$message .= '<b>Name:</b> ' . $name . '<br/>';
$message .= '<b>Email:</b> ' . $email . '<br/>';
if ( ! empty( $permalink ) ) {
$message .= '<b>Website:</b> ' . $permalink . '<br/>';
}
if ( ! empty( $phone ) ) {
$message .= '<b>Phone:</b> ' . $phone . '<br/>';
}
if ( ! empty( $company ) ) {
$message .= '<b>Company:</b> ' . $company . '<br/>';
}
$message .= '<b>Message:</b> ' . $text . '<br/>';
$headers = array();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=UTF-8';
// Additional headers
$headers[] = 'From:'.$name.' <' . $email . '>';
mail( $mail_to, $mail_subject, $message, implode("\r\n", $headers) );