Nếu bạn từng truy cập trang này. Hãy nhấn tổ hợp phím “Ctrl + F5” hoặc “Ctrl + Shift + R” (đối với máy sử dụng hệ điều hành Windows) hoặc “Command + Shift + R” (đối với máy sử dụng MACOS) để cập nhật phiên bản mới nhất.
Rất đơn giản, chỉ cần copy nội dung như thế này và dán vào trước thẻ </body>
<script> const code = '35A4EBED'; // ID vòng quay const formHeading = 'Quay để nhận thưởng'; const formDesc = 'Điền đúng thông tin để nhận quà'; const formButton = 'Thử vận may'; const iconPosition = 'right'; // vị trí icon mặc định là right (left hoặc right) const hideMail = false; // ẩn email đi. Mặc định false const lifetime = 60;// người dùng được chơi lại sau bao nhiêu phút const popupWhenExit = true;// hiển thị popup khi định thoát trang function sendByMe(args){ // Bạn phải viết hàm gửi email về cho người nhận lead này. console.log(args);//return object {code,name,phone,email,toEmail,result} \n\t'; console.log(args.code); console.log(args.name); // ..... } </script> <script src="https://vongquaymayman.co/popup.min.js"></script>
1. Javascript
<script> function sendByMe(args){ var code = args.code, name = args.name, phone = args.phone, email = args.email, toEmail = args.toEmail, result = args.result; // gửi email var xhr = new XMLHttpRequest(); xhr.open('POST', '/path-to/ajax.php?action=sendEmail'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function() { if (xhr.status === 200) { alert(xhr.responseText); } else if (xhr.status !== 200) { console.log("error:"+xhr.status ); } }; xhr.send('&name='+name+'&phone='+phone+'&email='+email+'&toEmail='+toEmail+'&code='+code+'&result='+result); } </script>
2. PHP
Tạo file php có tên là ajax.php hoặc tên gì tuỳ bạn miễn sao tên và thư mục phải giống với đã gọi ở mục javascript phía trên.
<?php $action = $_REQUEST["action"]; if($action==="sendEmail"){ sendEmailAction(); } function sendEmailAction(){ $name = $_POST["name"]; $phone = $_POST["phone"]; $email = $_POST["email"]; $toEmail = $_POST["toEmail"]; $result = $_POST["result"]; // return array ["ket qua 1","ket qua 2",...] $to = $toEmail; $subject = "Kết quả quay vòng quay may mắn ID:".$code; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $message = '<p>'.$name.' vừa quay VQMM có ID là '.$code.'.</p>'; $message .= '<p>Họ tên:'.$name.'</p>'; $message .= '<p>Điện thoại:'.$phone.'</p>'; $message .= '<p>Email:'.$email.'</p>'; $message .= '<p>Kết quả quay:'</p>'; $message .= '<ul>'; foreach($result as $ketqua){ $message .= '<li>'.$ketqua.'</li>'; } $message .= '</ul>'; // More headers $headers .= 'From:' . "\r\n"; $headers .= 'Cc: myboss@example.com' . "\r\n"; mail($to,$subject,$message,$headers); } ?>
Lưu ý: Bạn cần phải kiểm tra xem host có hỗ trợ gửi email không, nếu không hỗ trợ, có thể bạn phải sử dụng cách gửi email thông qua SMTP.
Tham khảo thêm: Làm thế nào để gửi email bằng PHP