/web/htdocs/www.micro-la.com/home/open/invia_contatti.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
<?php
include('backend/_classes.php');
$classes= new classes;
include(
'ld_PHPMailer/class.phpmailer.php');
$data = array();
$emailPrincipale 'info@micro-la.com'//loru.daniel@gmail.com
$data['success'] = '';
if(!empty(
$_POST)){
    
$nome $_POST['name'];
    
$mai $_POST['mail'];
    
$sito $_POST['sito'];
    
$message $_POST['message'];
    
$ogg $_POST['oggetto'];
    
    
$body1  "
                <html>
                    <head>
                    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
                    <title>"
.$classes->trad('Microla Optoelectronics S.r.l. - Richiesta Contatti''Microla Optoelectronics S.r.l. - Richiesta Contatti')."</title>
            
            
                    </head>
                    <body style='background-color:#EEE'>
            
            
            
                    <table align='center' style='margin:0 auto;' width='600' border='0' cellspacing='0' cellpadding='0' >
                        
                    <tr>
                    <td valign='top' class='body'>
                    <table style='background-color:#FFF!important;' width='100%' border='0' cellspacing='0' cellpadding='0'>
                    <tbody style='background-color:#FFF!important;'>
                    <tr>
                    
                        <td width='560' valign='top'  align='left' style='background-color:#FFF'>
                        <img src='http://www.micro-la.com/open/mailing/header.jpg' />
                        <br/>
                        <tr >
                        <td style='padding-left:20px; background-color:#FFF;' >
                        <h3 style='color:rgb(38, 32, 68); font-family:sans-serif'>"
.$classes->trad('Microla Optoelectronics S.r.l. - Richiesta Contatti''Microla Optoelectronics S.r.l. - Richiesta Contatti')."</h3>
                        </td></tr>
                        
                        <tr><td style=' padding-left:20px; background-color:#FFF;'>
                        <p style='color:#000; font-family:sans-serif'>
                        
                        "
.$classes->trad('Caro/a''Caro/a')." <strong>".ucfirst(strtolower($nome))."</strong><br />
                        "
.$classes->trad('ringrazia mail''Ti ringraziamo per averci contattato,<br/>
                        Ti ricontatteremo il prima possibile'
)."<br/><br/>
                        
                        <strong style='color: #000!important;'>Microla Optoelectronics S.r.l.</strong><br/><br/>
                        
                        </p></td></tr><br /><br /><br /><br />
                            
                        </td>
                        </tr>
                            
                        </td>
                    
                    </tr>
                    </tbody>
                    </table>
                    </td>
                    </tr>
                        
                    </table>
            
            
            
                    </body>
                </html>"
;
                
                
            
//NO MANDRILL
                
$phpmail = new PHPMailer();
                
$phpmail->IsSMTP();
                
$phpmail->Host 'in-v3.mailjet.com';
                
$phpmail->Port 587;
                
$phpmail->SMTPAuth true;
                
$phpmail->Username 'b03f2d8a8635cb50706d35ce57adfe7e';
                
$phpmail->Password '99778cb554f21ffb7b20d494e7e9359d';
                
$phpmail->From       'info@micro-la.com';
                
$phpmail->FromName   "Microla Optoelectronics S.r.l.";
                
$phpmail->AddAddress($mai);
                
$phpmail->Subject  $classes->trad('Microla Optoelectronics S.r.l. - Richiesta Contatti''Microla Optoelectronics S.r.l. - Richiesta Contatti');
                
$phpmail->MsgHTML($body1);
                
$phpmail->IsHTML(true); // send as HTML
                
$phpmail->Send();
                
//NO MANDRILL END    
                
                
                
        
$body2  "
                <html>
                    <head>
                    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
                    <title>"
.$classes->trad('Microla Optoelectronics S.r.l. - Richiesta Contatti''Microla Optoelectronics S.r.l. - Richiesta Contatti')."</title>
            
            
                    </head>
                    <body style='background-color:#EEE'>
            
            
            
                    <table align='center' style='margin:0 auto;' width='600' border='0' cellspacing='0' cellpadding='0' >
                        
                    <tr>
                    <td valign='top' class='body'>
                    <table style='background-color:#FFF!important;' width='100%' border='0' cellspacing='0' cellpadding='0'>
                    <tbody style='background-color:#FFF!important;'>
                    <tr>
                    
                        <td width='560' valign='top'  align='left' style='background-color:#FFF'>
                        <img src='http://www.micro-la.com/open/mailing/header.jpg' />
                        <br/>
                        <tr >
                        <td style='padding-left:20px; background-color:#FFF;' >
                        <h3 style='color:rgb(38, 32, 68); font-family:sans-serif'>"
.$classes->trad('Microla Optoelectronics S.r.l. - Richiesta Contatti''Microla Optoelectronics S.r.l. - Richiesta Contatti')."</h3>
                        </td></tr>
                        
                        <tr><td style=' padding-left:20px; background-color:#FFF;'>
                        <p style='color:#000; font-family:sans-serif'>
                        
                        L'utente "
.ucfirst(strtolower($nome))." ha inviato un messaggio sul sito Microla Optoelectronics<br><br>
                        <strong>Nome</strong>: "
.ucfirst(strtolower($nome))."<br/>
                        <strong>Email</strong>: "
.$mai."<br/>
                        <strong>Sito Web</strong>: "
.$sito."<br/>
                        <strong>Richiesta</strong>: "
.$ogg."<br/>
                        <strong>Messaggio</strong>: "
.$message."<br/>
                        <br/><br/>
                        
                        <strong style='color: #000!important;'>Microla Optoelectronics S.r.l.</strong><br/><br/>
                        
                        </p></td></tr><br /><br /><br /><br />
                            
                        </td>
                        </tr>
                            
                        </td>
                    
                    </tr>
                    </tbody>
                    </table>
                    </td>
                    </tr>
                        
                    </table>
            
            
            
                    </body>
                </html>"
;
                
                
            
//NO MANDRILL
                
$phpmail = new PHPMailer();
                
$phpmail->IsSMTP();
                
$phpmail->Host 'in-v3.mailjet.com';
                
$phpmail->Port 587;
                
$phpmail->SMTPAuth true;
                
$phpmail->Username 'b03f2d8a8635cb50706d35ce57adfe7e';
                
$phpmail->Password '99778cb554f21ffb7b20d494e7e9359d';
                
$phpmail->From       'info@micro-la.com';
                
$phpmail->FromName   "Microla Optoelectronics S.r.l.";
                
$phpmail->AddAddress($emailPrincipale);
                
$phpmail->Subject  $classes->trad('Microla Optoelectronics S.r.l. - Richiesta Contatti''Microla Optoelectronics S.r.l. - Richiesta Contatti');
                
$phpmail->MsgHTML($body2);
                
$phpmail->IsHTML(true); // send as HTML
                
$phpmail->Send();
                
//NO MANDRILL END    
                
    
require_once('include/MCAPI.class.php');
    
/*$api = new MCAPI('876522173d2e3c3fa766f7c7c7aab0d9-us16');
    $list_id = "e4ec525dc9"; // ID UNIVOCO DEL CLIENTE (lo recuperiamo qui:  https://us4.admin.mailchimp.com/lists/settings?id=27597
    $merge_vars = array(
    'FNAME'=>$nome, 
    'LNAME'=>'', 
    'COMPANY'=>''
    );
    $retval = $api->listSubscribe( $list_id, $mai, $merge_vars, 'html', false,true,true,false);*/
    
    //ISCRIZIONE SU MAILCHIMP
    // Getting params from URL
    
$email $mai;
    
$fname $nome;
    
$apikey '876522173d2e3c3fa766f7c7c7aab0d9-us16';
    
$list_id 'e4ec525dc9'// Setting -> List name and defaults -> List ID
    
    
    
$apiKey '876522173d2e3c3fa766f7c7c7aab0d9-us16'//Account -> Extra -> API keys -> Create A Key
    
$listId 'e4ec525dc9'// Setting -> List name and defaults -> List ID
    
$memberId md5(strtolower($mai));
    
$dataCenter substr($apiKey,strpos($apiKey,'-')+1);
    
$url 'https://' $dataCenter '.api.mailchimp.com/3.0/lists/' $listId '/members/' $memberId;
    
    
$arrayName = array();
    
$arrayName['email_address'] = $email;
    
$arrayName['status'] = 'subscribed';
    
$arrayName['merge_fields'] = array('FNAME'=>$fname);
    
    
$json json_encode($arrayName);
    
    
//print_r($json);
    
$ch curl_init($url);
    
curl_setopt($chCURLOPT_USERPWD'user:' $apiKey);
    
curl_setopt($chCURLOPT_HTTPHEADER, array('Content-Type: application/json'));  
    
//curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_TIMEOUT10);
    
curl_setopt($chCURLOPT_CUSTOMREQUEST'PUT');
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($chCURLOPT_POSTFIELDS$json);                                                                                                                 
    
$result curl_exec($ch);
    
$httpCode curl_getinfo($chCURLINFO_HTTP_CODE);
    
curl_close($ch);
    
/*ISCIZIONE NEWSLETTER*/
    
    
    
    
$data['success'] = 'success';
}
echo 
json_encode($data);


?>