3v4l.org

run code in 300+ PHP versions simultaneously
<html> <head> <title> Enviando E-mail... </title> <meta charset="UTF-8"> </head> <body> <?php // primeiro de tudo, faça uma validação nos campos para não enviar o email em branco // vou fazer só uma aqui, como exemplo // se não existir o campo email, "mata" todo o código if (!isset($_POST['email'])) { die(); } $emaildestino = $_POST['subcategoria']; $nome = $_POST['nome']; $sobrenome = $_POST['sobrenome']; $email = $_POST['email']; $telefone = $_POST['telefone']; $descricao = $_POST['mensagem']; $arquivo = $_FILES["arquivo"]; $boundary = "XYZ-".date("dmYis")."-ZYX"; $fp = fopen($arquivo["tmp_name"], "rb"); $anexo = fread($fp, filesize($arquivo["tmp_name"])); $anexo = base64_encode($anexo); fclose($fp); // cabeçalho do email $headers = "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=\"$boundary\"\r\n"; $headers .= "From: $email\n"; $headers .= "$boundary\n"; // email $data = "--$boundary\n"; $data .= "Content-Type: text/html; charset='utf-8'\n"; $data .= "<strong>Nome: </strong> $nome \r\n"; $data .= "<strong>Sobrenome: </strong> $sobrenome \r\n"; $data .= "<strong>E-mail: </strong> $email \r\n"; $data .= "<strong>Telefone: </strong> $telefone \r\n"; $data .= "<strong>Menssagem: </strong> $descricao \r\n"; $data .= "--$boundary \n"; // anexo $data .= "Content-Type: ".$arquivo["type"]."; name=".$arquivo['name']."\n"; $data .= "Content-Transfer-Encoding: base64 \n"; $data .= "Content-Disposition: attachment; filename=".$arquivo['name']."\r\n"; $data .= "$anexo \n"; $data .= "--$boundary \n"; $send = mail($emaildestino, "Email do Site Rastro Legal - Habilitações/Divergências", $data, $headers); if (!$send) { echo 'Ocorreu algum erro, tente novamente'; die(); } ?> <META HTTP-EQUIV=REFRESH CONTENT='0; URL=habilitacoes-e-divergencias'> <script type="text/javascript">alert("Mensagem Enviada com Sucesso.");</script> </body> </html>
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
<html> <head> <title> Enviando E-mail... </title> <meta charset="UTF-8"> </head> <body>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <html> <head> <title> Enviando E-mail... </title> <meta charset="UTF-8"> </head> <body>

preferences:
164.64 ms | 402 KiB | 156 Q