473,785 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

headers not working

4 New Member
I've uploaded a site to a new server and now the headers in the mail function are not working to send the required email response. This is a newly acquired site and my php knowledge is at the beginner level. I've managed to list the headers that are being sent but I can't seem to find where or why the email won't work. I'd really appreciate some help checking to see if there is an error in one of the header lines or perhaps the redirection.

Expand|Select|Wrap|Line Numbers
  1. <?
  2. /*
  3.     Name:           eMail
  4.     Description:    Simple sending eMail in text and HTML with CC, BCC and attachment
  5.     Version:        1.0
  6.     last modified:  2004-05-14
  7.      Leave this header in this file!
  8. */
  9.  
  10. class eMail
  11. {
  12.     var $to = array();
  13.     var $cc = array();
  14.     var $bcc = array();
  15.     var $attachment = array();
  16.     var $boundary = "";
  17.     var $header = "";
  18.     var $subject = "";
  19.     var $body = "";
  20.  
  21.     function eMail($name,$mail)
  22.     {
  23.         $this->boundary = md5(uniqid(time()));
  24.         $this->header .= "From: $name <$mail>\n";
  25.     }
  26.  
  27.     function to($mail)
  28.     {
  29.         $this->to[] = $mail;
  30.     }
  31.  
  32.     function cc($mail)
  33.     {
  34.         $this->cc[] = $mail;
  35.     }
  36.  
  37.     function bcc($mail)
  38.     {
  39.         $this->bcc[] = $mail;
  40.     }
  41.  
  42.     function attachment($file)
  43.     {
  44.         $this->attachment[] = $file;
  45.     }
  46.  
  47.     function subject($subject)
  48.     {
  49.         $this->subject = $subject;
  50.     }
  51.  
  52.     function text($text)
  53.     {
  54.         $this->body = "Content-Type: text/plain; charset=ISO-8859-1\n";
  55.         // try without this $this->body .= "Content-Transfer-Encoding: 8bit\n\n";
  56.         $this->body .= $text."\n";
  57.     }
  58.  
  59.     function html($html)
  60.     {
  61.         $this->body = "Content-Type: text/html; charset=ISO-8859-1\n";
  62.         //$this->body .= "Content-Transfer-Encoding: quoted-printable\n\n";
  63.         //$this->body .= "<html><body>\n".$html."\n</body></html>\n";
  64.         $this->body .= "\n".$html."\n\n";
  65.     }
  66.  
  67.     function send()
  68.     {
  69.         // CC Empfänger hinzufügen
  70.         $max = count($this->cc);
  71.         if($max>0)
  72.         {
  73.             $this->header .= "Cc: ".$this->cc[0];
  74.             for($i=1;$i<$max;$i++)
  75.             {
  76.                 $this->header .= ", ".$this->cc[$i];
  77.             }
  78.             $this->header .= "\n";
  79.         }
  80.         // BCC Empfänger hinzufügen
  81.         $max = count($this->bcc);
  82.         if($max>0)
  83.         {
  84.             $this->header .= "Bcc: ".$this->bcc[0];
  85.             for($i=1;$i<$max;$i++)
  86.             {
  87.                 $this->header .= ", ".$this->bcc[$i];
  88.             }
  89.             $this->header .= "\n";
  90.         }
  91.         $this->header .= "MIME-Version: 1.0\n";
  92.         $this->header .= "Content-Type: multipart/mixed; boundary=$this->boundary\r\n";
  93.         $this->header .= "This is a multi-part message in MIME format\n";
  94.         $this->header .= "--$this->boundary\n";
  95.         $this->header .= $this->body;
  96.  
  97.         // Attachment hinzufügen
  98.         $max = count($this->attachment);
  99.         if($max>0)
  100.         {
  101.             for($i=0;$i<$max;$i++)
  102.             {
  103.                 $file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
  104.                 $this->header .= "--".$this->boundary."\n";
  105.                 $this->header .= "Content-Type: application/x-zip-compressed; name=".$this->attachment[$i]."\n";
  106.                 $this->header .= "Content-Transfer-Encoding: base64\n";
  107.                 $this->header .= "Content-Disposition: attachment; filename=".$this->attachment[$i]."\r\n";
  108.                 $this->header .= chunk_split(base64_encode($file))."\n";
  109.                 $file = "";
  110.             }
  111.         }
  112.         $this->header .= "--".$this->boundary."--\r\n";
  113.  
  114.         foreach($this->to as $mail)
  115.         {
  116.            // print ("<pre>" .$this->header. "<pre>");
  117.             mail ($mail, $this->subject,"", $this->header);
  118.         }
  119.     }
  120. }
  121. ?>
When the email is sent this is what is output for the headers:

From: with domain name
Bcc: with email
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=1220aa be3151c7827740f bbfd644047d

This is a multi-part message in MIME format
--1220aabe3151c78 27740fbbfd64404 7d
Content-Type: text/html; charset=ISO-8859-1

at the bottom of the email output the boundary is output again and

Warning: cannot modify header information - headers already sent by (output started at "the name of this file is listed here)???

I don't know where to go from here. It seems to be finding the includes file but then I get the Warning message. Should output buffering be added to the includes files? I'm not sure what headers to try and fix or comment out. I would really appreciate some help. I'm trying to figure out the importance of each header but I'm confused by what is necessary to allow the email to be sent.
Apr 24 '09 #1
2 1851
Markus
6,050 Recognized Expert Expert
The error will have given you a number, too. More specifically, a line number. Can you tell us that please?

Also, when posting code, please use [code] tags. Thank you.
Apr 24 '09 #2
urbanedge
4 New Member
Hi there,

Here are the error msgs. When I add output buffering to the acciones_class_ confirmation_pr ofesores.php file it gets rid of the header error but the email is still not sending. I'm having a difficult time figuring out where to look for the errors. The help is greatly appreciated.



Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/c/a/n/canmex/html/teaching/acciones/class_mail.php on line 121

Warning: Cannot modify header information - headers already sent by (output started at /home/content/c/a/n/canmex/html/teaching/acciones/class_mail.php: 121) in /home/content/c/a/n/canmex/html/teaching/acciones/acciones_class_ confirmation_pr ofesores.php on line 31



Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3.  
  4. /****************** INCLUDES SRC************************/
  5. require_once "../../src/config/config.php";
  6.  
  7. include ('../../src/common/base_datos/class.bd.php');
  8. include ('../../src/common/base_datos/funcManejo.php');
  9.  
  10. include ('../../src/functions/procesar.php');
  11. include ('../../src/functions/estructurasTablas.php');
  12.  
  13. include ('../../src/functions/imagenes.php');
  14. include ('../../src/functions/misc.php');
  15.  
  16. /****************** INCLUDES FRONT************************/
  17. include ('../includes/functions_profesores.php');
  18. include ('../../includes/functions_alumnos.php'); 
  19.  
  20. include ('../../function_generales/functions_generales_mail.php');
  21. include ('../../function_generales/functions_generales.php');
  22. $bd = crearConexion();
  23.  
  24. $aClase = darDatosClase($_POST['id_clase']);
  25.  
  26. switch ($_POST['accion']) {
  27.  
  28.     case 'confirm':
  29.         if(cambiarEstadoClase($_POST['id_clase'], CLASE_ACEPTADA)){            
  30.             enviarEmail('clase_invitacion_confirmada', 'Your class is CONFIRMED!' , $aClase['alu_email'] , $aClase);
  31.             header("Location: ../mainProfesor.php"); die();
  32.         }
  33.  
  34.     break;
  35.  
  36.     case 'refuse': 
  37.         if(cambiarEstadoClase($_POST['id_clase'], CLASE_CANCELADA)){
  38.             enviarEmail('clase_invitacion_cancelada', 'Your class was NOT confirmed.' , $aClase['alu_email'] , $aClase);
  39.             header("Location: ../mainProfesor.php"); die();
  40.         }
  41.     break;
  42.  
  43. }
  44. ?>
Apr 27 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1899
by: Justin Haygood | last post by:
I want to use multiple custom headers in the mail() function. I know the basic syntax is mail(recipient, subject, content, optional headers). How would I use like say 3 headers? Also, what would the custom header be to set the Content-Type to text/html (for some reason Content-Type: text/html isn't working). Thank you very much, Justin Haygood Xion Digital Networks (www.xiondigital.net)
0
2215
by: Hal Vaughan | last post by:
I'm working with javax.mail.*. I have no problem with reading in messages. I'm not using multi-part messages or anything, I just use this setup: Session oSession = Session.getDefaultInstance(props, null); try { oStore = oSession.getStore("pop3"); oStore.connect(sInServer, sInName, sInPass); oFolder = oStore.getFolder("INBOX"); oFolder.open(Folder.READ_WRITE); oMessage = oFolder.getMessages();
5
4573
by: Simran | last post by:
I need to set up an automated email system , which means users should not be able to respond back to the emails but at the same time, we need to track bounced emails. This is important as our customers are paying for this service, so we need to track the bounced email Id's. This is the code which I have tried:- MailMessage msgRequest = new MailMessage(); msgRequest.BodyFormat = MailFormat.Text; msgRequest.Subject = "Do Not reply to...
71
4238
by: Christopher Benson-Manica | last post by:
At what point was the .h dropped from the STL headers? I just had a discussion yesterday with my boss, who said he wanted .h on all the STL includes, despite me protesting that it was not standard... -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
0
2650
by: john bailo | last post by:
I am attempting to create a c# program to iterate through the messages in an Outlook/Exchange public folder and extract the headers. My apologies to the VB/VBA groups, but you seem to have more information for Office automation than the c# groups. I am having some problems manipulating the various object models. I say various because based on what source code I could find, I am trying to use the Outlook, CDO and MAPI type libraries
0
1199
by: CFloyd | last post by:
I have a web service client that sends an XML string to the web service for processing. I alos have to add some headers to the post. I first establish the baseuri as === baseuri = new Uri("http://192.168.100.67/mimservice/mimosawebservice.asmx/MWS32Service === Then I pass the uri and the xml string along to another method the includes: === HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create( url);
22
2231
by: Platero | last post by:
Hi, I've a stupid question but... The code is the following: if(($role!='tutor')&&(array_key_exists('tutor_id',$_GET))) { $possible_ids = array(2,6,7,8,9,10); $t_id = $_GET;
8
1593
by: Spartacus | last post by:
Oops, I meant to write: function send_mail($to_name, $to_email, $from_name, $from_email, $subject, $message) { $thedate = date("r", time()); $headers = "X-Mailer: PHPMailProgram/1.0\n"; $headers .= "From: \"".$from_name."\" <".$from_email.">\n";
4
1853
by: sadieslc | last post by:
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what I'm doing wrong? Here is the script: <? function send_mail($emailaddress, $fromaddress, $emailsubject, $body) { $eol="\r\n"; $mime_boundary=md5(time()); # Common Headers
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.