Ir ao conteúdo
  • Cadastre-se

Pagina de contato


juliodovalle

Posts recomendados

Bom dia galera!!! :)

Apesar da hora estou aqui tentando resolver um problema sou curioso na área mais estou começando um curso técnico agora.

O problema é o seguinte eu não sei configurar um send-email.php não tenho nem ideia pra onde vai aonde devo colocar o e-mail no qual quero receber os mesmo. E quando coloco no site a pagina de contato preencho tudo certinho ele aparece uma mensagem entra na tela o código php. Ou seja quando eu envio ao invés de voltar a home ele aparece códigos. Alguém poderia me ajudar com esse problema? Vou enviar o código espero que vocês possa me ajudar... Grato desde já!

 

 

<?php/** * Define the from email */ // emaildefine('TO_EMAIL', '[email protected]'); define('FROM_EMAIL', 'juliomanoel.pe!hotmail.com');  define('FROM_NAME', 'Test'); /** * define the body of the email. You can add some shortcode, with this format: %ID% *  * ID = the id have you insert on the html markup. *  * e.g. * <input type="text" name="email" /> *        * You can add on BODY, this: * email: %email%    */ define( 'BODY', '%message%<br /><br /><small>email inviata da %name%, email %email%.</small>' );define( 'SUBJECT', 'Email from yoursite.com' );// here the redirect, when the form is submitteddefine( 'ERROR_URL', 'contact-error.php' );define( 'SUCCESS_URL', 'contact-success.php' ); define( 'NOTSENT_URL', 'contact-notsent.php' );           // the message feedback of ajax request$msg = array(    'error' => '<p class="error">Warning! Fill correctly the fields marked in red</p>',    'success' => '<p class="success">Email sent correctly. Thanks to get in touch us!</p>',    'not-sent' => '<p class="error">An error has been encountered. Please try again.</p>');          // the field required, by name$required = array( 'name', 'email', 'message' );/** * Send the email. *  * SERVER-SIDE: the functions redirect to some URL, in base of result of control and send. * The urls must be set in the constants above: ERROR_URL, SUCCESS_URL, NOTSENT_URL *  * CLIENT-SIDE: in js/contact.js, there is already script for real-time checking of fields * and for ajax request of send email, that request in this page (sendmail.php) and echo the feedback message.     */   sendemail();                     // NO NEED EDITfunction sendemail() {                                    global $msg, $required;        if ( isset( $_POST['ajax'] ) )        $ajax = $_POST['ajax'];    else        $ajax = false;    if ( isset( $_POST['yit_action'] ) AND $_POST['yit_action'] == 'sendmail' ) {                                  $body = BODY;      $post_data = array_map( 'stripslashes', $_POST );   //      print_r($post_data);//      die;      foreach ( $required as $id_field ) {            if( $post_data[$id_field] == '' || is_null( $post_data[$id_field] ) ) {             if ( $ajax )                end_ajax( $msg['error'] );             else             redirect( ERROR_URL );         }                            }      if( !is_email( $post_data['email'] ) OR $post_data['email'] == '' )        if ( $ajax )          end_ajax( $msg['error'] );       else            redirect( ERROR_URL );        foreach( $post_data as $id => $var )   {    if( $id == 'message' ) $var = nl2br($var);$body = str_replace( "%$id%", $var, $body ); }   $headers  = 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";$headers .= 'From: '.FROM_NAME.' <'.FROM_EMAIL.'>' . "\r\n" . 'Reply-To: ' . $post_data['email'];   $sendmail = mail( TO_EMAIL, SUBJECT, $body, $headers );        if ( $sendmail )        if ( $ajax )          end_ajax( $msg['success'] );       else            redirect( SUCCESS_URL );   else       if ( $ajax )          end_ajax( $msg['not-sent'] );       else            redirect( NOTSENT_URL );} }function is_email($email) {    if (!preg_match("/[a-z0-9][_.a-z0-9-]+@([a-z0-9][0-9a-z-]+.)+([a-z]{2,4})/" , $email))    {        return false;    }    else    {        return true;    }}             function end_ajax( $msg = '' ) {    echo $msg;    die;}           function redirect( $redirect = '' ) {    header( 'Location: ' . $redirect );    die;}      ?>

sendmail.PHP

Link para o comentário
Compartilhar em outros sites

Se a sua ideia é só mandar o email isso basta:
 

<?php$message = "blablablabla \n balbalbalasdasd \n balbalbab .";$message = wordwrap($message, 70);mail('[email protected]', 'Assunto', $message);?>

O ideal é que você coloque o header, mas da pra mandar sem header . . . Tipo o exemplo acima eu não coloquei header

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!