Mail & session headers

software development


HI, I try to send a email with mail function using html headers, the problem is that I need to registrer sessions() in the same page, and function mail give me error if I do it. What I’m doing worng? or what can I do? thanks

<?php session_start(); error_reporting(E_ALL); @ini_set('display_errors', '1'); if(isset($_SESSION['carro'])) $carro=$_SESSION['carro'];else $carro=false; $pipo=""; $pipo=$pipo.""; $pipo=$pipo.""; $pipo=$pipo.""; $pipo=$pipo.""; $pipo=$pipo.""; $color=array('#ffffff','#F0F0F0'); $contador=0; $suma=0; foreach($carro as $k => $v){ $subto=$v['cantidad']*$v['precio']; $suma=$suma+$subto; $contador++; $pipo=$pipo." "; $pipo=$pipo.""; $pipo=$pipo.""; $pipo=$pipo.""; $pipo=$pipo.""; } $pipo=$pipo."
ProductoPrecioCantidad de Unidades
"; // multiples recipientes $para = ''; // asunto $asunto = 'Pedido a traves de la WEB'; // mensaje $mensaje = $pipo; // Para enviar correo HTML, la cabecera Content-type debe definirse $cabeceras = 'MIME-Version: 1.0' . "\r\n"; $cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Cabeceras adicionales $cabeceras .= 'To: Joan , Joan JGC ' . "\r\n"; $cabeceras .= 'From: Recordatorio de Cumpleańos ' . "\r\n"; // Enviarlo mail($para, $asunto, $mensaje, $cabaceras); ?>


I’m not going to pretend to be an expert on this topic (I usually avoid sending HTML emails), but I don’t think the session is causing your header issue. I’ve used sessions and sent mail many times and never had this issue.

I’ve often used PHPMailer. It has many settings (including html email). Maybe you should try using that and see if your email sends with the sessions still on that script. If it works, then you know the headers aren’t the real issue.

I hope that helps. :slight_smile: - a great PHPMailer Tutorial

Angela Gann
CrimsonDryad Web Design Services
Web Design, Custom Software Development