Como puedo mandar archivos adjuntos por email con php
Tengo un formulario con datos del usuario y que adjunte imágenes pero no me sirve, me manda los datos ej: nombre. Email. Tel, comentario pero no me manda las imágenes.
Te mando el script php:
<?php
$attachment = array ("http://www.sinergiavirtual.com.ar/unaimagen.jpg");
$message="Return-Path: sender@email"
Subject: This is the subject line
From: Andrés <sender@email>
X-Sender: <sender@email>
X-Mailer: PHP 4.3.11
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="Next_5CAC45F405A04C4486878BB22F052778"
This is a multi-part message in MIME format.
--Next_5CAC45F405A04C4486878BB22F052778
Content-Type: multipart/related;
boundary="Next_91B9A9555A93173413A5FBBB55300A3E"
--Next_91B9A9555A93173413A5FBBB55300A3E
Content-Type: text/html;
charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
<img src="cid:unaimagen.jpg">
--Next_91B9A9555A93173413A5FBBB55300A3E
Content-Type: image/jpeg;
name="unaimagen.jpg"
Content-ID: <unaimagen.jpg>
Content-Disposition: inline;
filename="unaimagen.jpg"
Content-Transfer-Encoding: base64
';
$attfile = $attachment[0];
$file_name = basename ($attfile);
$fp = fopen ($attfile, "r");
$fcontent = "";
while (!feof ($fp))
{
$fcontent .= fgets ($fp, 1024);
}
$fcontent = chunk_split (base64_encode($fcontent));
@fclose ($fp);
$message.=$fcontent;
$message.='
--Next_91B9A9555A93173413A5FBBB55300A3E--
--Next_5CAC45F405A04C4486878BB22F052778--
';
mail ("[email protected]", 'hola', '', $message);
}
?>
y este es el mensaje de error
Warning: filesize(): Stat failed for 193753 (errno=2 - No such file or directory) in D:\Ftp\LocalUser\sinergiavirtual\Public_html\enviar.php on line 45
Su formulario ha sido enviado con éxito
Te mando el script php:
<?php
$attachment = array ("http://www.sinergiavirtual.com.ar/unaimagen.jpg");
$message="Return-Path: sender@email"
Subject: This is the subject line
From: Andrés <sender@email>
X-Sender: <sender@email>
X-Mailer: PHP 4.3.11
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="Next_5CAC45F405A04C4486878BB22F052778"
This is a multi-part message in MIME format.
--Next_5CAC45F405A04C4486878BB22F052778
Content-Type: multipart/related;
boundary="Next_91B9A9555A93173413A5FBBB55300A3E"
--Next_91B9A9555A93173413A5FBBB55300A3E
Content-Type: text/html;
charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
<img src="cid:unaimagen.jpg">
--Next_91B9A9555A93173413A5FBBB55300A3E
Content-Type: image/jpeg;
name="unaimagen.jpg"
Content-ID: <unaimagen.jpg>
Content-Disposition: inline;
filename="unaimagen.jpg"
Content-Transfer-Encoding: base64
';
$attfile = $attachment[0];
$file_name = basename ($attfile);
$fp = fopen ($attfile, "r");
$fcontent = "";
while (!feof ($fp))
{
$fcontent .= fgets ($fp, 1024);
}
$fcontent = chunk_split (base64_encode($fcontent));
@fclose ($fp);
$message.=$fcontent;
$message.='
--Next_91B9A9555A93173413A5FBBB55300A3E--
--Next_5CAC45F405A04C4486878BB22F052778--
';
mail ("[email protected]", 'hola', '', $message);
}
?>
y este es el mensaje de error
Warning: filesize(): Stat failed for 193753 (errno=2 - No such file or directory) in D:\Ftp\LocalUser\sinergiavirtual\Public_html\enviar.php on line 45
Su formulario ha sido enviado con éxito
1 Respuesta
Respuesta de Jorge Vila