problema con AddAttachment
Publicado por zendi (1058 intervenciones) el 06/01/2015 14:07:10
Que tal a todos, Tengo este codigo que si envia los correos normalmente, pero no esta enviando los archivos adjuntos
Si algien pudiera ayudarme con la sintaxis
en negrillas estan comentados los que he probado pero no funcionan.
este es el formulario:
este es le codigo que procesa
Si algien pudiera ayudarme con la sintaxis
en negrillas estan comentados los que he probado pero no funcionan.
este es el formulario:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
form {
margin: 1em auto;
text-align: center;
}
span{
color: #F60;
font-size: 1.5 em;
}
</style>
</head>
<body>
<form name="mail_frm" method="post" enctype="multipart/form-data" action="enviar.php">
De:<input type="text" name="de_txt" /> <br/> <br/>
Para:<input type="text" name="para_txt" /> <br/> <br/>
Asunto:<input type="text" name="asunto_txt" /> <br/> <br/>
Adjuntar Archivo: <input type="file" name="archivo_fls" /> <br/> <br/>
Mensaje:<br /><textarea name= "mensaje_txa"/> </textarea> <br/> <br/>
<input type="submit" name="enviar_btn" value="Enviar"/><br/>
<?php
if(isset($_GET["respuesta"])){
echo "<span>".$_GET["respuesta"] ."</span>";
}
?>
</form>
</body>
</html>
este es le codigo que procesa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
require("PHPMailer-master/class.phpmailer.php");
require("PHPMailer-master/class.smtp.php");
$de = $_POST["de_txt"];
$para = $_POST["para_txt"];
$asunto = $_POST["asunto_txt"];
$archivo = $_FILES["archivo_fls"]["tmp_name"];
$destino = $_FILES["archivo_fls"]["name"];
$mensaje = $_POST["mensaje_txa"];
if(move_uploaded_file($archivo,$destino))
{
$smtp=new PHPMailer(); # Indicamos que vamos a utilizar un servidor SMTP
$smtp->IsSMTP(); # Definimos el formato del correo con UTF-8
$smtp->CharSet="UTF-8";
$smtp->SMTPDebug = 1; # autenticación contra nuestro servidor smtp
$smtp->SMTPAuth = true; // enable SMTP authentication
$smtp->SMTPSecure = "tls";
$smtp->Host = "smtp.live.com"; // sets MAIL as the SMTP server
$smtp->Username = "andresmen2004@hotmail.com"; // MAIL username
$smtp->Password = "*******"; // MAIL password
$smtp->Port = 587; # datos de quien realiza el envio
$smtp->From = "alecuello84@hotmail.com"; // from mail
$smtp->FromName = "Alejo"; // from mail name # Indicamos la dirección donde enviar el mensaje
$para="alecuello84@hotmail.com";
$nameTo="Alejon";
$smtp->AddAddress($para,$nameTo);
$smtp->Subject = $asunto;
$smtp->Body = $mensaje;
$smtp->WordWrap = 50;
$smtp->Timeout=30;
$smtp->IsHTML(true);
$smtp->MsgHTML($mensaje);
// $smtp->AddAttachment($archivo["tmp_name"], $archivo["name"]);
// $smtp->AddAttachment($archivo);
// $smtp->AddAttachment('archivos/$archivo','nombre');
// $smtp->AddAttachment($_FILES["archivo_fls"]["tmp_name"],$_FILES["archivo_fls"]["name"]);
if (!$smtp->Send())
{
$respuesta ="El mensaje no se pudo enviar";
$respuesta .="Error: " .$mail->ErrorInfo;
}
else
{
$respuesta ="El mensaje ha sido enviado";
}
}
else
{
$respuesta = "Ocurrio un error";
}
header("Location:correomail.php?respuesta=$respuesta");
?>
Valora esta pregunta


0