enviarCorreoBolsa.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <?php
  2. if (isset($_POST['nombreBolsa'])) {
  3. $nombreBolsa = $_POST['nombreBolsa'];
  4. $apellidosBolsa = $_POST['apellidosBolsa'];
  5. $correoBolsa = $_POST['correoBolsa'];
  6. $numeroBolsa = $_POST['numeroBolsa'];
  7. $codigoPostal = $_POST['codigoPostal'];
  8. $ciudadBolsa = $_POST['ciudadBolsa'];
  9. $pais = $_POST['pais'];
  10. $comentariosBolsa = $_POST['comentariosBolsa'];
  11. //variables para los datos del archivo
  12. $nameFile = $_FILES['curriculum']['name'];
  13. $sizeFile = $_FILES['curriculum']['size'];
  14. $typeFile = $_FILES['curriculum']['type'];
  15. $tempFile = $_FILES["curriculum"]["tmp_name"];
  16. //Archivo 2
  17. $nameFile2 = $_FILES['carta']['name'];
  18. $sizeFile2 = $_FILES['carta']['size'];
  19. $typeFile2 = $_FILES['carta']['type'];
  20. $tempFile2 = $_FILES["carta"]["tmp_name"];
  21. $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
  22. $recaptcha_secret = '6LcCmZ8UAAAAAE1Jzojch6baCHm_7UWGxVZMkgiL';
  23. $recaptchaGet = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
  24. $recaptcha = json_decode($recaptchaGet,true);
  25. // Miramos si se considera humano o robot:
  26. // echo json_encode($recaptcha);
  27. /*if ($recaptcha['success'] == true) {
  28. if($recaptcha['score'] >= 0.1){*/
  29. //enviamos el correo
  30. enviarCorreo($nombreBolsa,$apellidosBolsa,$correoBolsa,$numeroBolsa,$codigoPostal,$ciudadBolsa,$pais,$comentariosBolsa,
  31. $nameFile,$sizeFile,$typeFile,$tempFile,$nameFile2,$sizeFile2,$typeFile2,$tempFile2);
  32. /* }else{
  33. controlError(false,"No hemos podido descubrir que eres un humano, por favor recarga la Página");
  34. }
  35. }else{
  36. controlError(false,"Captcha repetido o invalido, favor de recargar la Página.");
  37. }*/
  38. }
  39. function enviarCorreo($nombreBolsa,$apellidosBolsa,$correoBolsa,$numeroBolsa,$codigoPostal,$ciudadBolsa,$pais,$comentariosBolsa,
  40. $nameFile,$sizeFile,$typeFile,$tempFile,$nameFile2,$sizeFile2,$typeFile2,$tempFile2){
  41. //Se crea una clave única para identificar que es un mismo correo
  42. $uniqueid= uniqid('np');
  43. $to = "marketing@rake.mx";
  44. $subject = "CONTACTO WEB";
  45. $cabeceras = 'MIME-Version: 1.0' . "\r\n";
  46. //El correo contendrá diferente contenido
  47. $cabeceras .= "Content-Type: multipart/mixed;boundary=" . $uniqueid. "\r\n";
  48. $cabeceras .= 'From: Rake MX<web@rake.mx>' . "\r\n";
  49. $body .= "\r\n\r\n--" . $uniqueid. "\r\n";
  50. $body .= "Content-type: text/html;charset=utf-8\r\n\r\n";
  51. $body .= "<!DOCTYPE html>
  52. <html>
  53. <head>
  54. <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
  55. <meta content='width=device-width, initial-scale=1' name='viewport'>
  56. <title>You're invited!</title>
  57. <!-- Designed by https://github.com/kaytcat -->
  58. <!-- Robot header image designed by Freepik.com -->
  59. <style type='text/css'>
  60. @import url(http://fonts.googleapis.com/css?family=Droid+Sans);
  61. /* Take care of image borders and formatting */
  62. img {
  63. max-width: 600px;
  64. outline: none;
  65. text-decoration: none;
  66. -ms-interpolation-mode: bicubic;
  67. }
  68. a {
  69. text-decoration: none;
  70. border: 0;
  71. outline: none;
  72. color: #bbbbbb;
  73. }
  74. a img {
  75. border: none;
  76. }
  77. /* General styling */
  78. td,
  79. h1,
  80. h2,
  81. h3 {
  82. font-family: Helvetica, Arial, sans-serif;
  83. font-weight: 400;
  84. }
  85. td {
  86. text-align: center;
  87. }
  88. body {
  89. -webkit-font-smoothing: antialiased;
  90. -webkit-text-size-adjust: none;
  91. width: 100%;
  92. height: 100%;
  93. color: #37302d;
  94. background: #ffffff;
  95. font-size: 16px;
  96. }
  97. table {
  98. border-collapse: collapse !important;
  99. }
  100. .headline {
  101. color: #ffffff;
  102. font-size: 36px;
  103. }
  104. .force-full-width {
  105. width: 100% !important;
  106. }
  107. .force-width-80 {
  108. width: 80% !important;
  109. }
  110. </style>
  111. <style media='screen' type='text/css'>
  112. @media screen {
  113. /*Thanks Outlook 2013! */
  114. td,
  115. h1,
  116. h2,
  117. h3 {
  118. font-family: 'Droid Sans', 'Helvetica Neue', 'Arial', 'sans-serif' !important;
  119. }
  120. }
  121. </style>
  122. <style media='only screen and (max-width: 480px)' type='text/css'>
  123. /* Mobile styles */
  124. @media only screen and (max-width: 480px) {
  125. table[class='w320'] {
  126. width: 320px !important;
  127. }
  128. td[class='mobile-block'] {
  129. width: 100% !important;
  130. display: block !important;
  131. }
  132. }
  133. </style>
  134. </head>
  135. <body bgcolor='#FFFFFF' class='body' style='padding:0; margin:0; display:block; background:#ffffff; -webkit-text-size-adjust:none'>
  136. <div style='width:0; opacity:0; max-height:0; mso-hide:all; overflow:hidden; float:left; display:none !important;''>
  137. Se ha realizado una solicitud de empleo desde la página web www.rake.mx
  138. </div>
  139. <table align='center' cellpadding='0' cellspacing='0' class='force-full-width'>
  140. <tbody>
  141. <tr>
  142. <td align='center' bgcolor='#FFFFFF' valign='top' width='100%'>
  143. <center>
  144. <table cellpadding='0' cellspacing='0' class='w320' style='margin: 0 auto;' width='600'>
  145. <tbody>
  146. <tr>
  147. <td align='center' valign='top'>
  148. <table bgcolor='#fff' cellpadding='0' cellspacing='0' class='force-full-width' style='margin: 0 auto;'>
  149. <tbody>
  150. <tr>
  151. <td style='font-size: 30px; text-align:center;padding: 10px;'>
  152. <img alt='Rake' class='500' height='70' src='http://rake.mx/webQA/assets/logo.png'>
  153. </td>
  154. </tr>
  155. </tbody>
  156. </table>
  157. <table bgcolor='#4DBFBF' cellpadding='0' cellspacing='0' class='force-full-width' style='margin: 0 auto;'>
  158. <tbody>
  159. <tr>
  160. <td><br>
  161. <img alt='robot picture' height='240' src='https://www.filepicker.io/api/file/carctJpuT0exMaN8WUYQ' width='224'>
  162. </td>
  163. </tr>
  164. <tr>
  165. <td class='headline'><br>
  166. <strong>Nueva Solicitud de Empleo </strong><br>
  167. </td>
  168. </tr>
  169. <tr>
  170. <td>
  171. <center>
  172. <table cellpadding='0' cellspacing='0' style='margin: 0 auto;' width='60%'>
  173. <tbody>
  174. <tr>
  175. <td style='font-size:18px;color:#fff;'><br> Se ha recibido una nueva solicitud de empleo desde la página web Rake MX<br>
  176. <br> Nombre: ".$nombreBolsa."
  177. <br> Teléfono: ".$numeroBolsa."
  178. <br> Correo electrónico: ".$correoBolsa."
  179. <br> Codigo Postal: ".$codigoPostal."
  180. <br> Ciudad: ".$ciudadBolsa."
  181. <br> Pais: ".$pais."
  182. <br> Comentarios: ".$comentariosBolsa."<br> <br>
  183. </td>
  184. </tr>
  185. </tbody>
  186. </table>
  187. </center>
  188. </td>
  189. </tr>
  190. <tr>
  191. <td>
  192. <br>
  193. <br>
  194. <br>
  195. <br>
  196. </td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. <table bgcolor='#F5774E' cellpadding='0' cellspacing='0' class='force-full-width' style='margin: 0 auto;'>
  201. <tbody>
  202. <tr>
  203. <td style='background-color:#f5774e;'>
  204. <center></center>
  205. </td>
  206. </tr>
  207. </tbody>
  208. </table>
  209. <table bgcolor='#414141' cellpadding='0' cellspacing='0' class='force-full-width' style='margin: 0 auto;'>
  210. <tbody>
  211. <tr>
  212. <td style='background-color:#414141;'><br><br>
  213. </td>
  214. </tr>
  215. <tr>
  216. <td style='color:#bbbbbb; font-size:12px;'>
  217. <br>
  218. <br>
  219. </td>
  220. </tr>
  221. </tbody>
  222. </table>
  223. </td>
  224. </tr>
  225. </tbody>
  226. </table>
  227. </center>
  228. </td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. </body>
  233. </html>";
  234. $body .= "\r\n\r\n--" . $uniqueid. "\r\n";
  235. $body .= "Content-Type: application/octet-stream; ";
  236. $body .= "name=" . $nameFile . "\r\n";
  237. $body .= "Content-Transfer-Encoding: base64\r\n";
  238. $body .= "Content-Disposition: attachment; ";
  239. $body .= "filename=" . $nameFile . "\r\n";
  240. $body .= "\r\n"; // línea vacía
  241. $fp = fopen($tempFile, "rb");
  242. $file = fread($fp, $sizeFile);
  243. $file = chunk_split(base64_encode($file));
  244. $body .= "$file\r\n";
  245. // Adjunto 2
  246. $body .= "\r\n\r\n--" . $uniqueid. "\r\n";
  247. $body .= "Content-Type: application/octet-stream; ";
  248. $body .= "name=" . $nameFile2 . "\r\n";
  249. $body .= "Content-Transfer-Encoding: base64\r\n";
  250. $body .= "Content-Disposition: attachment; ";
  251. $body .= "filename=" . $nameFile2 . "\r\n";
  252. $body .= "\r\n"; // línea vacía
  253. $fp2 = fopen($tempFile2, "rb");
  254. $file2 = fread($fp2, $sizeFile2);
  255. $file2 = chunk_split(base64_encode($file2));
  256. $body .= "$file2\r\n";
  257. $body .= "\r\n"; // línea vacía
  258. // Delimitador de final del mensaje.
  259. if(!mail($to,$subject,$body, $cabeceras)){
  260. controlError(false,"No se pudo enviar el email al administrador.");
  261. }else{
  262. controlError(success,"La solicitud de empleo ha sido enviada exitosamente.");
  263. }
  264. }
  265. function controlError($succes,$mensaje) {
  266. $response = array('success'=>$succes,'mensaje'=>$mensaje);
  267. echo json_encode($response);
  268. }
  269. ?>