Ir para conteúdo

POWERED BY:

Arquivado

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

Marcela Romero

enviar formulario para email

Recommended Posts

pessoal tenho o seguinte formulario

<center> <form  id="formulario" name="formulario" method="post" action="teste.php">
  <p>Nome:</p>
  <p>
  <input type="text" name="nome" id="nome" /><br />
  <span id="erroNome"></span>
  </p>
  <p> </p>
  <p>E-mail:
    <label for="email"></label>
    <input type="text" name="email" id="email" /><br />
    <span id="erroEmail"></span>
  </p>
  <p> </p>
  <p>Assunto:
    <label for="assunto"></label>
    <select name="assunto" id="assunto">
    <option value="" selected="selected">Selecione...</option>
      <option value="Sugestões/Elogios">Sugestões/ Elogios</option>
      <option value="Informações / Dúvidas">Informações / Dúvidas</option>
      <option value="Reclamações">Reclamações</option>
      <option value="Outros">Outros</option>
    </select><br />
    <span id="erroAssunto"></span>
  </p>
  <p> </p>
  <p>Mensagem</p>
  <p>
    <label for="mensagem"></label>
    <textarea name="mensagem" id="mensagem" cols="45" rows="5"></textarea><span id="erroMensagem"></span>
  </p>
  <p> </p>
  <p>Como conheceu nosso site?</p>
  <p>
    <input type="radio" name="radio" id="propaganda2" value="propaganda" onclick="JavaScript: formulario.opcradio.value='a';" />
  Indicação de um amigo</p>
  <p>
    <input type="radio" name="radio" id="propaganda" value="propaganda" onclick="JavaScript: formulario.opcradio.value='w';" />
    Pesquisa na web</p>
  <p>
    <input type="radio" name="radio" id="propaganda3" value="propaganda" onclick="JavaScript: formulario.opcradio.value='p';" />
    Propaganda</p><span id="erroConheceu"></span>
  <p> </p>
  <p>
    <input type="Button" value="Enviar" onClick="JavaScript: teste_submit();">
    <input type="reset" name="Limpar" id="Limpar" value="Limpar" />
  </p>
  <input type="hidden" name="opcradio" id="opcradio" />
</form></center>

 

e quero que ao preencher os dados o mesmo seja enviado para o email, fiz o seguinte codigo para envio...aparece mensagem de enviado porem nao chega o email, qual será o erro

 

<?php
	$destinatario = "leticiacardosoalves@yahoo.com.br";
		$assunto = $_POST["assunto"];
		$corpo = '
					<html>
					<head>
					   <title>dados clientes</title>
					</head>
					<body>
					      Olá.<br/><br/>
					<h1>Olá '.$_POST["nome"].'!</h1>
					<p>
					<br/>O e-mail do cliente: <b>'.$_POST["email"].'</b>.
					</p>
					
				
					<p>
					<br/>Mensagem: <b>'.$_POST["mensagem"].'</b>.
					</p>
					
					<p>
					<br/>Como conheceu o site: <b>'.$_POST["radio"].'</b>.
					</p>
					
					</body>
					</html>
					'; 
	
		//para o envio em formato HTML
		$headers = "MIME-Version: 1.0\r\n";
		$headers .= "Content-Type: text/html; charset=UTF-8;\r\n";
					
		//endereço do remetente
		$headers .= "From: Conex <leticiacardosoalves@yahoo.com.br>\r\n";
					
		//endereço de resposta, se queremos que seja diferente a do remetente
		$headers .= "Reply-To: leticiacardosoalves@yahoo.com.br\r\n";
				
		if(mail($destinatario,$assunto,$corpo,$headers))
		{
			echo '<script>   history.go(-1); alert("mensagem enviada com sucesso!"); </script>';
			return;	
		}
		else{
			echo '<script>   history.go(-1); alert("Erro!"); </script>';
			return;
		}
	

?>

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

obrigada pela dica, verifiquei porem como estou começando nessa área ficou um pouco confuso...ja tenho os codigos acima e neles gostaria de saber se há algo de errado... no meu caso estou usando localhost

Compartilhar este post


Link para o post
Compartilhar em outros sites

Para enviar um e-mail você precisa de um servidor de e-mail e no caso de estar no windows vai precisar simular o sendmail também, se você instalou apenas um WAMP da vida você não tem estes ítens, logo o e-mail nunca vai chegar porque ele nunca foi enviado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

eu utilizo o Xampp porem configurei o sendmail.ini e o php.ini como descrito no video... ao fazer o teste aparece mensagem enviada porem o email nao chega... o que mais devo fazer...ja tentei de tudo

Compartilhar este post


Link para o post
Compartilhar em outros sites

Marcela vc realmente tem que enviar este email localmente ? pq senão use um servidor real para testar sua aplicação provavelmente vc não esta errando o codigo mas o problema pode estar simplesmente em tentar enviar de um servidor local (simulador).

Compartilhar este post


Link para o post
Compartilhar em outros sites

estou desenvolvendo meu tcc e por isso estou usando servidor local... mas se encontrar outra saida eu aceito... tudo para que esse form funcione...como posso usar um servidor real...algum gratuito para eu subir e testar o envio do email

Compartilhar este post


Link para o post
Compartilhar em outros sites

Use o www.000webhost.com

o melhor free que conheço. rs

Maaaas tem outro muito bom e barato.

 

http://www.royalhosting.com.br/

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ricardo eu tirei a virgula e a configuração do sendmail é a seguinte

 

 

; configuration for fake sendmail
; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail
[sendmail]
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.
smtp_server=smtp.google.com
; smtp port (normally 25)
smtp_port=tls
; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL
smtp_ssl=auto
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
;default_domain=www.cotejasupermercados.com.br
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
;debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username=meu email do gmail
auth_password=minha senha
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.
pop3_server=
pop3_username=
pop3_password=
; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content
force_sender=
; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content
force_recipient=
; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required
hostname=


Use o www.000webhost.com

o melhor free que conheço. rs

Maaaas tem outro muito bom e barato.

 

http://www.royalhosting.com.br/

Obrigada ... vou tentar mais algumas alternativas e se nao der certo eu subo pro servidor real... é que no meu caso subiria só pra testar ja que no momento nao vai para o ar o site

Compartilhar este post


Link para o post
Compartilhar em outros sites

sempre coloque no servidor pra testar antes da conclusão do projeto teste quantas vezes for preciso e sempre que tiver dúvida porque tem varios erros que devido a configuração do servidor local não são exibidos, dessa forma se seu site tiver muitos erros você evita que eles acabem se acumulando e surpeendam você de última hora :D

Compartilhar este post


Link para o post
Compartilhar em outros sites

Marcela Romero, sua configurações do arquivo sendmail.ini estão incoretas.

Segue abaixo as configurações para usar com gmail.

 

; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=587

; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL

smtp_ssl=tls

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=mydomain.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

;debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=seu_email@gmaill.com
auth_password=sua_senha


; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.

pop3_server=
pop3_username=
pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content

force_sender=

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content

force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required

hostname=

 

Altere as linha abaixo com as informações de sua conta de e-mail.

 

auth_username=seu_email@gmaill.com
auth_password=sua_senha

Compartilhar este post


Link para o post
Compartilhar em outros sites

Marcela Romero, sua configurações do arquivo sendmail.ini estão incoretas.

Segue abaixo as configurações para usar com gmail.

 

 

Altere as linha abaixo com as informações de sua conta de e-mail.

ah sim Ricardo...eu coloquei...somente alterei para poder postar aqui, senao ia aparecer meu email e minha senha..rsrs, porem mesmo assim ocorre erro

Compartilhar este post


Link para o post
Compartilhar em outros sites

Marcela na forma que estava configurado o seu sendamil.ini estava incorreta.

 

Aqui algumas das linhas das quais estavão incorretas:

 

smtp_server=smtp.google.com
smtp_port=tls
smtp_ssl=auto

 

Coreto

 

smtp_server=smtp.gmail.com

smtp_port=587

smtp_ssl=tls

 

Ja no assim agora o problema pode esta no seguinte na configuração do seu php.ini

Confira na linha sendmail_path caso tenha ; antes sendamail_path é só retirar.

 

sendmail_path = 'DIRETORIO ONDE ESTA O SENDMAIL\sendmail -t';

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ricardo, antes de mais nada, obrigada pela ajuda.

 

Alterei conforme vc sugeriu..

 

o php.ini ja estava correto: sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

 

Porem aparece msg enviada mas email nao chega...sera que nao vou conseguir enviar por servidor local

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Na locaweb fiz 300 teste e nunca funcionou para mim o Xampp, dai fiz esse formulário que envia sem problema segue código:

index.html

<form action="envia.php" method="POST" onSubmit="return verificar_form(this)" class="row">
						<div class="span3">
							<label>Nome</label>
							<input type="text" name="name" placeholder="Seu nome" />
						</div>
						<div class="span3">
							<label>E-mail</label>
							<input type="email" name="email" placeholder="@" />
						</div>
						<div class="span6">
							<label>Mensagem</label>
							<textarea style="width:450px" name="message" rows="4" placeholder="Deixe-nos a sua mensagem"></textarea>
							<p>
                            	<input type="submit" value="Enviar!" class="button yellow fr"/>
							</p>
						</div>
						<input type="hidden" name="bot" value="" />
					</form>

 

envia.php

<?
$mensagem = "Nome: ".$_POST['name']." \n";
$mensagem .= "E-mail: ".$_POST['email']." \n";
$mensagem .= "Mensagem: ". $_POST['message'];
$headers = "";
//email do seu domínio hospedado
$emailsender = "seuemail@seucominio.com.br";
//email de quem vai receber
$emaildestinatario = "seuemail@seucominio.com.br";
$assunto = "Mensagem do formulário";

// Envio dos dados do Formulário para seu e-mail:
if(!mail($emaildestinatario, $assunto, $mensagem, $headers ,"-r".$emailsender))

{
// Se for Postfix - hospedagem linux
$headers .= "Return-Path: " . $emailsender . $quebra_linha;
}
echo '
<script type="text/JavaScript">
alert("Seu e-mail foi enviado com sucesso. Obrigado");
location.href="contato.php"
</script>
';

?> 



			
		

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.