Ir para conteúdo

POWERED BY:

Arquivado

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

Guilherme Strich

Envio de e-mail para outros assuntos

Recommended Posts

Boa tarde pessoal,

Tudo bem?

 

Então, gostaria de um auxilio de vocês para um problema que estou tendo no envio de e-mail por um formulário de contato.

O lance é que o formulário tem um campo de assunto, e conforme cada 1 dos assuntos ele deve enviar para um e-mail X.

Fiz um código e joguei no ar, aparentemente funcionou, deu a mensagem de enviado com sucesso, mas quando vou verificar no webmail se ele chegou, o e-mail não chega, acho que devo estar fazendo algo errado, se puderem me ajudar ficarei muito agradecido.

 

Arquivo: contato.asp

<?xml version="1.0" encoding="utf-8"?>

<script language="javascript" type="text/javascript" src="/gerenciador/funcoes/mascara.js"></script>
<script>
	function verifica_contato(formulario)
		{
			if (formulario.nome.value == '') 
				{
					alert("Campo NOME está em branco!");
					formulario.nome.focus();
					return (false);
				}
			var formato = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
			if(!formato.test(formulario.email.value))
				{
					alert("O campo E-MAIL está incorreto!");
					formulario.email.focus();
					return false;
				}
			if (formulario.telefone.value.length < 13)
				{
					alert("Campo TELEFONE inválido!");
					formulario.telefone.focus();
					return (false);
				}
			if (formulario.cidade.value == '')
				{
					alert("Campo CIDADE está em branco!");
					formulario.cidade.focus();
					return (false);
				}
			if (formulario.uf.value.length < 2)
				{
					alert("Campo UF inválido!");
					formulario.uf.focus();
					return (false);
				}
			if (formulario.mensagem.value == '')
				{
					alert("Campo MENSAGEM está em branco!");
					formulario.mensagem.focus();
					return (false);
				}
		}
</script>
<%
	If request("langue") <> "" Then
		sNom = "Nombre"
		sTel = "Teléfono"
		sMen = "Mensaje"
		sTxt2 = "Ventas"
		sConct = "Contacto"
	Else
		sNom = "Nome"
		sTel = "Telefone"
		sMen = "Mensagem"
		sTxt2 = "Tecidos"
		sConct = "Contato"
	End If
if request("nome") = "" then%>
	<form action="/contato/send_contato.asp" method="post" name="formulario">
		<table align="left">
			<tr><td width="10%"></td></tr>
			<tr height="20"><td></td></tr>
			<tr>
				<td style="padding:2px; " align="right"><b><%=sConct%>:</b></td>
				<td style="padding:2px; ">
					<select name="para" class="caixa">
						<option value="maquinas">Máquinas</option>
						<option value="tecidosmoda"><%=sTxt2%></option>
					</select>
				</td>
			</tr>
			<tr>
				<td style="padding:2px; " align="right"><b><%=sNom%>:</b></td>
				<td style="padding:2px; "><input type="text" class="caixa" name="nome" size="32" style="vertical-align:middle;"></td>
			</tr>
			<tr>
				<td style="padding:2px; " align="right"><b><%=sTel%>:</b></td>
				<td style="padding:2px; "><input style="vertical-align:middle;" onkeypress="if(this.value.charAt(0)!='('){this.value='('+this.value;}return mascara(event,this,'###)####-####');" type="text" class="caixa" maxlength="13" name="telefone" size="32"></td>
			</tr>
			<tr>
				<td style="padding:2px; " align="right"><b>E-mail:</b></td>
				<td style="padding:2px; "><input type="text" class="caixa" name="email" size="32" style="vertical-align:middle;"></td>
			</tr>
			<%=cCidadeI%>
			<tr>
				<td style="padding:2px;" align="right"><b>Cidade / UF:</b></td>
				<td style="padding:2px;">
					<input type="text" class="caixa" name="cidade" size="24" style="vertical-align:middle;">
					/
					<select name="uf" class="caixa" style="width:50px; ">
						<option value="Selecione...">...</option>
						<option value="AC" <%if sUf = "AC" then%>selected<%end if%>>AC</option>
						<option value="AL" <%if sUf = "AL" then%>selected<%end if%>>AL</option>
						<option value="AM" <%if sUf = "AM" then%>selected<%end if%>>AM</option>
						<option value="AP" <%if sUf = "AP" then%>selected<%end if%>>AP</option>
						<option value="BA" <%if sUf = "BA" then%>selected<%end if%>>BA</option>
						<option value="CE" <%if sUf = "CE" then%>selected<%end if%>>CE</option>
						<option value="DF" <%if sUf = "DF" then%>selected<%end if%>>DF</option>
						<option value="ES" <%if sUf = "ES" then%>selected<%end if%>>ES</option>
						<option value="GO" <%if sUf = "GO" then%>selected<%end if%>>GO</option>
						<option value="MA" <%if sUf = "MA" then%>selected<%end if%>>MA</option>
						<option value="MG" <%if sUf = "MG" then%>selected<%end if%>>MG</option>
						<option value="MS" <%if sUf = "MS" then%>selected<%end if%>>MS</option>
						<option value="MT" <%if sUf = "MT" then%>selected<%end if%>>MT</option>
						<option value="PA" <%if sUf = "PA" then%>selected<%end if%>>PA</option>
						<option value="PB" <%if sUf = "PB" then%>selected<%end if%>>PB</option>
						<option value="PE" <%if sUf = "PE" then%>selected<%end if%>>PE</option>
						<option value="PI" <%if sUf = "PI" then%>selected<%end if%>>PI</option>
						<option value="PR" <%if sUf = "PR" then%>selected<%end if%>>PR</option>
						<option value="RJ" <%if sUf = "RJ" then%>selected<%end if%>>RJ</option>
						<option value="RN" <%if sUf = "RN" then%>selected<%end if%>>RN</option>
						<option value="RO" <%if sUf = "RO" then%>selected<%end if%>>RO</option>
						<option value="RR" <%if sUf = "RR" then%>selected<%end if%>>RR</option>
						<option value="RS" <%if sUf = "RS" then%>selected<%end if%>>RS</option>
						<option value="SC" <%if sUf = "SC" then%>selected<%end if%>>SC</option>
						<option value="SE" <%if sUf = "SE" then%>selected<%end if%>>SE</option>
						<option value="SP" <%if sUf = "SP" then%>selected<%end if%>>SP</option>
						<option value="TO" <%if sUf = "TO" then%>selected<%end if%>>TO</option>
					</select>
				</td>
			</tr>
			<%=cCidadef%>
			<tr>
				<td style="padding:2px; " align="right" valign="top"><b><%=sMen%>:</b></td>
				<td style="padding:2px;"><textarea class="caixa" name="mensagem" cols="31" rows="5" style="vertical-align:middle;"></textarea></td>
			</tr>
			<tr>
				<td></td>
				<td style="padding:2px;"><input type="submit" value="Enviar Mensagem" class="caixa" onclick="return verifica_contato(formulario);"></td>
			</tr>
			</td></tr>
		</table>
	</form>
<%else%>
	<table width="100%" height="200">
		<tr>
			<td align="center" style="letter-spacing:2px; line-height:25px;"><font color="red"><b><%=request("nome")%></b>, sua mensagem foi eviada!<br>Em breve entraremos em contato!</font></td>
		</tr>
	</table>
<%end if%>

Código do send_contato.asp

<%
	On Error Resume Next
	
	ip			= request.servervariables("remote_addr")
	nome		= trim(replace(request.form("nome"),chr(39),"''"))
	email		= trim(replace(request.form("email"),chr(39),"''"))
	telefone	= trim(replace(request.form("telefone"),chr(39),"''"))
	cidade		= trim(replace(request.form("cidade"),chr(39),"''"))
	uf			= ucase(trim(replace(request.form("uf"),chr(39),"''")))
	mensagem	= trim(replace(request.form("mensagem"),chr(39),"''"))
	data2		= trim(replace(request.form("data"),chr(39),"''"))
	data 		= date
	hora 		= time
	sPara        = trim(replace(request.form("para"),chr(39),"''"))
	If sPara = "maquinas" Then
		destino = "email1@email.com"
	Else
		destino = "email2@email.com"
	End If
	
	corpo = "<html><head><style>a:link,a:visited{text-decoration: none;color:black;}a:active,a:hover{text-decoration: underline;color: black;}</style></head><body><table align='center' width='500' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'><tr><td height='76'><a href='http://" & site & "' target='_blank'><img src='http://" & site & topo & "' border='0'></a></td></tr><tr><td align='center' style='padding-top:10px; '><font color='black' face='tahoma'><h3>Contato</h3></font></td></tr><tr><td style='padding-top:10px; padding-left: 40px; line-height:18px;'><table width='90%'>"

	corpo = corpo & "<tr><td style='font-family:tahoma; font-size:11px; color: black' align='right'><b>NOME:					</b></td><td style='font-family:tahoma; font-size:11px; color: black; padding-left:5px;' width='340'>" & nome & "</td></tr>"
	corpo = corpo & "<tr><td style='font-family:tahoma; font-size:11px; color: black' align='right'><b>E-MAIL:					</b></td><td style='font-family:tahoma; font-size:11px; color: black; padding-left:5px;' width='340'><a href='mailto:" & email & "'>" & email & "</a></td></tr>"
	corpo = corpo & "<tr><td style='font-family:tahoma; font-size:11px; color: black' align='right'><b>TELEFONE:				</b></td><td style='font-family:tahoma; font-size:11px; color: black; padding-left:5px;' width='340'>" & telefone & "</td></tr>"
	If sUsaCidade <> "s" Then
		corpo = corpo & "<tr><td style='font-family:tahoma; font-size:11px; color: black' align='right' nowrap><b>CIDADE / UF:		</b></td><td style='font-family:tahoma; font-size:11px; color: black; padding-left:5px;' width='340'>" & cidade & " / " & uf & "</td></tr>"
	End If
	corpo = corpo & "<tr><td style='font-family:tahoma; font-size:11px; color: black' align='right' valign='top'><b>MENSAGEM:	</b></td><td style='font-family:tahoma; font-size:11px; color: black; padding-left:5px;' width='340'>        " & replace(mensagem,chr(10),"<br>        ") & "</td></tr>"
	
	corpo = corpo & "<tr><td style='padding-top:30px; font-family:tahoma; font-size:11px; color: black' colspan='2' align='center'>Enviado dia " & date & " - " & time & "</td></tr></table></td></tr><tr><td height='20'></td></tr><tr><td align='right' style='font-size:10px; font-family:tahoma; padding: 5px; '><font color='black'>" & cliente & "</font></td></tr></table></body></html>"
	
	set mail = server.createobject("persits.mailsender") 
		mail.host = smtp
		mail.subject = "Contato - " & cliente
		Mail.AddCC destino, cliente
		mail.from = email
		mail.fromname =	nome
		mail.body = corpo
		mail.ishtml = true
		mail.send
	set mail = nothing

	If Err.Number <> 0 Then
		session("msg") = "A página pode conter erros."
'	Else
'		session("msg") = "Mensagem enviada com sucesso!"	
	End If

	response.Redirect "/monta.asp?link=contato&nome=" & nome
%>

 

Desde já agradeço a todos que conseguirem me ajudar

Obrigado!

Compartilhar este post


Link para o post
Compartilhar em outros sites

No final de seu código existe um If que carrega uma sesion com a mensagem de falha ou suces, mas o ELSE Está como comentário, retire a ' e teste novamente.

Compartilhar este post


Link para o post
Compartilhar em outros sites

No final de seu código existe um If que carrega uma sesion com a mensagem de falha ou suces, mas o ELSE Está como comentário, retire a ' e teste novamente.

 

O envio agora funcionou, recebi o e-mail, porem não está aparecendo os campos preenchidos, qual pode ser o erro?

Compartilhar este post


Link para o post
Compartilhar em outros sites

dá um response.write na sua variavel corpo , para ver o que esta sendo passado

response.write(corpo)
response.end()

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.