Seguinte Tenho o Seguinte Codigo em Pleno Funcionamento.
Porem Nao Consigo Por o Envio de Anexo. Espero que alguem possa me ajudar.
Segue o envia.php
<?php
if(isset($_POST['Send']) || isset($_POST['ajax'])){
$errorC = false;
$the_name = $_POST['yourname'];
$the_email = $_POST['email'];
$the_website = $_POST['website'];
$the_message = $_POST['message'];
$the_url = $_POST['imageURL'];
$the_subject = $_POST['Subject'];
# want to add aditional fields? just add them to the form in template_contact.php,
# you dont have to edit this file
//added fields that are not set explicit like the once above are combined and added before the actual message
$already_used = array('yourname','email','website','message','ajax','myemail','myblogname','Send','Subject','imageURL');
$attach = '';foreach ($_POST as $key => $field){
if(!in_array($key,$already_used)){$attach.= $key.": ".$field."
\n";}}$attach.= "
\n";
if(!checkmymail($the_email)){$errorC = true;$the_emailclass = "error";}else{$the_emailclass = "valid";}
if($the_name == ""){$errorC = true;$the_nameclass = "error";}else{$the_nameclass = "valid";}
if($the_message == ""){$errorC = true;$the_messageclass = "error";}else{$the_messageclass = "valid";}
if($the_subject != '') $the_subject = 'Subject: '.$the_subject."
";
if($the_url != '') $the_url = 'Preview Image: '.$the_url."
";
if($errorC == false)
{
$arquivo = $_FILES["arquivo"];
// Para quem vai ser enviado o email
$para = $_POST['myemail'];
// cabeçalho do email
$subject = "Contato do Site " . $_POST['myblogname'];
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$header .= 'From:'. $_POST['email'] . " \r\n";
$header .= "Content-Type: multipart/mixed; ";
$message1 = nl2br($_POST['message']);
$message .= "Nova Mensagem de:
Nome: $the_name
Email: $the_email
Website: $the_website
Mensagem: $message1
$the_subject
$the_url
$attach
\r\n";
// anexo
$message .= "$arquivo \n";
// enviar o email
mail($para,$subject,$message,$header);
if(isset($_POST['ajax'])){
echo"
Email Enviado Com Sucesso.
Obrigado!
";}}}
function checkmymail($mailadresse){
$email_flag=preg_match("!^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$!",$mailadresse);
return $email_flag;}
?>
Agora segue o formulario
<?php
$name_of_your_site = "WMServerS Servidores Online";
$email_adress_reciever = "[EMAIL]suporte@wmservers.com[/EMAIL]";
if(isset($_POST['Send']))
{
include('send.php');
}
?>
Formulário de Contato
<?php if (!isset($errorC) || $errorC == true){ ?>
Seu Nome*
E-Mail*
Website
Anexo
Sua Mensagem*
<?php } else { ?>
<?php } ?>
Obs: o envio funciona muito bem, porem nao consigo fazer que funcione com anexo.
Sera que pelo amor de Deus alguem pode me ajudar.