Te doy la bienvenida a nuestro sitio web, ahora hallarás la solucíon que buscabas.
Ejemplo 1: php envía correo electrónico con archivo adjunto
$filename='myfile';$path='your path goes here';$file=$path."/".$filename;$mailto='[email protected]';$subject='Subject';$message='My message';$content=file_get_contents($file);$content=chunk_split(base64_encode($content));// a random hash will be necessary to send mixed content$separator=md5(time());// carriage return type (RFC)$eol="rn";// main header (multipart mandatory)$headers="From: name <[email protected]>".$eol;$headers.="MIME-Version: 1.0".$eol;$headers.="Content-Type: multipart/mixed; boundary="".$separator.""".$eol;$headers.="Content-Transfer-Encoding: 7bit".$eol;$headers.="This is a MIME encoded message.".$eol;// message$body="--".$separator.$eol;$body.="Content-Type: text/plain; charset="iso-8859-1"".$eol;$body.="Content-Transfer-Encoding: 8bit".$eol;$body.=$message.$eol;// attachment$body.="--".$separator.$eol;$body.="Content-Type: application/octet-stream; name="".$filename.""".$eol;$body.="Content-Transfer-Encoding: base64".$eol;$body.="Content-Disposition: attachment".$eol;$body.=$content.$eol;$body.="--".$separator."--";//SEND Mailif(mail($mailto,$subject,$body,$headers))echo"mail send ... OK";// or use booleans hereelseecho"mail send ... ERROR!";print_r(error_get_last());
Ejemplo 2: enviar archivo adjunto en correo php
$filename='myfile';$path='your path goes here';$file=$path."/".$filename;$mailto='[email protected]';$subject='Subject';$message='My message';$content=file_get_contents($file);$content=chunk_split(base64_encode($content));// a random hash will be necessary to send mixed content$separator=md5(time());// carriage return type (RFC)$eol="rn";// main header (multipart mandatory)$headers="From: name <[email protected]>".$eol;$headers.="MIME-Version: 1.0".$eol;$headers.="Content-Type: multipart/mixed; boundary="".$separator.""".$eol;$headers.="Content-Transfer-Encoding: 7bit".$eol;$headers.="This is a MIME encoded message.".$eol;// message$body="--".$separator.$eol;$body.="Content-Type: text/plain; charset="iso-8859-1"".$eol;$body.="Content-Transfer-Encoding: 8bit".$eol;$body.=$message.$eol;// attachment$body.="--".$separator.$eol;$body.="Content-Type: application/octet-stream; name="".$filename.""".$eol;$body.="Content-Transfer-Encoding: base64".$eol;$body.="Content-Disposition: attachment".$eol;$body.=$content.$eol;$body.="--".$separator."--";//SEND Mailif(mail($mailto,$subject,$body,$headers))echo"mail send ... OK";// or use booleans hereelseecho"mail send ... ERROR!";print_r(error_get_last());
Ejemplo 3: archivo adjunto y mensaje de correo electrónico php
$my_file="somefile.zip";$my_path="/your_path/to_the_attachment/";$my_name="Olaf Lederer";$my_mail="[email protected]";$my_replyto="[email protected]";$my_subject="This is a mail with attachment.";$my_message="Hallo,rndo you like this script? I hope it will help.rnrngr. Olaf";mail_attachment($my_file,$my_path,"[email protected]",$my_mail,$my_name,$my_replyto,$my_subject,$my_message);
Ejemplo 4: como obtener archivos adjuntos a correos electrónicos php
usePHPMailerPHPMailerPHPMailer;usePHPMailerPHPMailerException;$email=newPHPMailer();$email->SetFrom('[email protected]','Your Name');//Name is optional$email->Subject='Message Subject';$email->Body=$bodytext;$email->AddAddress('[email protected]');$file_to_attach='PATH_OF_YOUR_FILE_HERE';$email->AddAttachment($file_to_attach,'NameOfFile.pdf');return$email->Send();
Tienes la opción de añadir valor a nuestra información aportando tu experiencia en las reseñas.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)