-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcontact-process.php
executable file
·83 lines (64 loc) · 3.25 KB
/
contact-process.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
<?php
require("admin/bootstrap.php");
include( dirname(__FILE__) . SYSPATH_CONNECTION );
include( dirname(__FILE__) . SYSPATH_LANG );
require_once ("includes/PHPMailer/class.phpmailer.php");
require("includes/Sql/sql.class.php");
/*
* BASIC POST sanitization
*/
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
/*
* Call data from database
*/
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
$array_empresa = GenericSql::getEmpresa( );
/*
* Print the order on the screen to confirm purposes
*/
$order_data = '<center><pre>';
$order_data .= '<a href="menu"><img src="images/logo/'.$array_empresa[logotipo].'" /></a><br />';
$order_data .= '<br />------------------------------------------------------------------------------------------<br />';
$order_data .= '<b> '.GENERAL_CONTACT_FORM.' </b>';
$order_data .= '<br />------------------------------------------------------------------------------------------<br />';
$order_data .= '<table width="500">';
$order_data .= '<tr><td>'.LBL_CUSTOMER_NAME.':</td> <td> ' . $_POST[feedback_name] . ' </td></tr>';
$order_data .= '<tr><td>'.LBL_CUSTOMER_PHONE1.':</td> <td> ' . $_POST[feedback_contact] . ' </td></tr>';
$order_data .= '<tr><td>'.LBL_CUSTOMER_EMAIL.':</td> <td> ' . $_POST[feedback_email] . ' </td></tr>';
$order_data .= '<tr><td>'.LBL_CUSTOMER_SUBJECT.':</td> <td> ' . $_POST[feedback_subject] . ' </td></tr>';
$order_data .= '<tr><td>'.LBL_CUSTOMER_COMMENT.':</td> <td> ' . $_POST[feedback_comment] . ' </td></tr>';
$order_data .= '</table>';
$order_data .= '------------------------------------------------------------------------------------------<br />';
$order_data .= '</pre></center>';
print $order_data; // print the receipt on screen
/*
* Send email to company (mail come from website user)
*/
//echo 'TO ' . $array_empresa['email'] . ' - FROM '. $_POST['feedback_email'];
try
{
$mail->AddReplyTo($_POST['feedback_email'], $_POST['feedback_name']);
$mail->AddAddress($array_empresa['email'], $array_empresa['nome_fantasia']); //TO
$mail->SetFrom($array_empresa['email'], $array_empresa['nome_fantasia']); //FROM
$mail->AddReplyTo($_POST['feedback_email'], $_POST['feedback_name']);
$mail->Subject = $array_empresa['nome_fantasia'] . ' - ' . GENERAL_CONTACT_FORM . ' - ' . $_POST['feedback_name'];
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($order_data);
$mail->AddAttachment('images/logo/logo_oficial.png'); // attachment
//$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "<center><pre><img src='images/icons/check-alt.png' /><br />" . MAIL_SENT_SUCCESS . $array_empresa['tel1'] . " <br /></pre></center> \n";
}
catch (phpmailerException $e)
{
echo $e->errorMessage(); //Pretty error messages from PHPMailer
}
catch (Exception $e)
{
echo $e->getMessage(); //Boring error messages from anything else!
}
/*
* Send back to contact form
*/
//GenericSql::Redirect($sec=60, $file="contato.php");
?>