Jump to content
cristpate

link no email

Recommended Posts

cristpate

como mandar um email com link np php?


craziness it's to do the same thing over and over again expecting a different result

Share this post


Link to post
Share on other sites
Patrijosa

olá este é um código que eu utilizo... pode modificar ele ...

html>
<head><title>Formulário de Envio de E-mail</title></head>
<body>

	<div style="padding-left: 50px;">
		<h3><img src='mail.png' width='24' /> Formulário de Contacto</h3>
		<div>
			<?php
				if (isset($_GET['action'])){
					$action = $_GET['action'];

					if ($action == "send"){

						// Definindo as Váriaveis...
						$deNome = $_POST['nome'];
						$deEmail = $_POST['email'];
						// $deMensagem = $_POST['mensagem']; 
                                                       $deMensagem = "Olá esta é uma mensagem com link.<br /><a href='www.google.com'>Google</a>";

						$ficheiro = isset($_FILES["anexo"]) ? $_FILES["anexo"] : FALSE;

						$fp = fopen($_FILES["anexo"]["tmp_name"],"rb");
						$anexo = fread($fp,filesize($_FILES["anexo"]["tmp_name"]));
						$anexo = base64_encode($anexo);
						fclose($fp);

						$anexo = chunk_split($anexo); 

						// Enviar mensagem para...
						$para = "info@patriciodossantos.net";

						// Assunto da Mensagem
						$assunto = $_POST['assunto'];

						$boundary = "XYZ-" . date("dmYis") . "-ZYX"; 

						$mens = "--$boundary\n";
						$mens .= "Content-Transfer-Encoding: 8bits\n";
						$mens .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n\n"; //plain
						$mens .= "$deMensagem\n";
						$mens .= "<hr />\n";
						$mens .= "Nome: $deNome\n";
						$mens .= "Email: $deEmail\n";
						$mens .= "--$boundary\n";
						$mens .= "Content-Type: ".$ficheiro["type"]."\n";
						$mens .= "Content-Disposition: attachment; filename=\"".$ficheiro["name"]."\"\n";
						$mens .= "Content-Transfer-Encoding: base64\n\n";
						$mens .= "$anexo\n";
						$mens .= "--$boundary--\r\n";

						$headers = "MIME-Version: 1.0\n";
						$headers .= "From: Contacto Visitante <contacto@sistec.co.ao>\r\n";
						$headers .= "Reply-To: \"$deNome\" <$deEmail>\r\n"; 
						$headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n";
						$headers .= "$boundary\n";

						// Enviando o E-mail
						if(mail($para, $assunto, $mens, $headers)){
							echo "<em style='margin: 10px;'><img src='ok.png' width='16' />Mensagem Enviada com sucesso!</em><br />";
						} else {
							echo "<em style='margin: 10px;'>Oops!!! Ocorreu um Erro ao enviar mensagem.</em><br />";
						}
					} else {
						echo "<em>Oops!!! Ocorreu um erro :-(</em>";
					}
				}
			?>
		</div>
		<form action="?action=send" method="post" name="sendmail" enctype="multipart/form-data" id="sendmail">
			<table>
				<tr><td width="30%">Nome:</td><td><input type="text" size="27" name="nome" /></td></tr>
				<tr><td>E-mail:</td><td><input type="text" size="27" name="email" /></td></tr>
				<tr><td>Assunto:</td><td><input type="text" size="27" name="assunto" /></td></tr>
				<tr><td>Anexo:</td><td><input type="file" size="13" name="anexo" /></td></tr>
				<tr><td colspan="2">Mensagem:<br /><textarea name="mensagem" cols="31" rows="5"></textarea></td></tr>
				<tr><td colspan="2"><input type="submit" value="Enviar..." /></td></tr>
			</table>
		</form>
	</div>
</body>
</html>
[code]

espero ter ajudado

cumps
PS


O verdadeiro sábio é um eterno aprendiz!

http://www.patriciodossantos.net

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.