'Failed to connect to mailserver' and 'Cannot modify header information' warnings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ROXIT
    New Member
    • Apr 2013
    • 10

    'Failed to connect to mailserver' and 'Cannot modify header information' warnings

    hello guyz.......

    please help me to sort out this warnings....



    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs \project\cateri ngcom\contactpr ocess.php on line 78

    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs \project\cateri ngcom\contactpr ocess.php on line 79

    Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs \project\cateri ngcom\contactpr ocess.php:83) in D:\xampp\htdocs \project\cateri ngcom\contactpr ocess.php on line 87


    Code:
    <?php
    	$name=$_POST['name'];
    	$email=$_POST['email'];
    	$phone=$_POST['phone'];
    	$message=$_POST['message'];
    	
    	// multiple recipients
    	$to_client  = $email;
    	$to_admin  = '[removed]';
    
    	// subject
    	$subject = 'Maya Technosoft - Details Received Successfully';
    
    	// message
    	$msg_client = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <table width="100%" cellpadding="5" cellspacing="5">
    	<tr align="center" bgcolor="#CC6600">
        	<td><font color="#FFFFFF" size="+3" face="Arial, Helvetica, sans-serif">MAYA TECHNOSOFT</font></td>
        </tr>
        <tr align="center">
        	<td><font face="Arial, Helvetica, sans-serif" color="#CC6600" size="+2">Thank You '.$name.' Your Details Received Successfully</font></td>
        </tr>
        <tr>
           	  	<td align="center" bgcolor="#F3F2F2">
              		<font face="Arial" size="3" color="#E12301">
                    	This is the confirmation email that we have received your detail successfully. Our support team member will contact you shortly. 
                    </font>
                    <br /><br />
                    <font face="Arial" size="2" color="#E12301">
                        Please do not reply this email, as this is an auto generated email.
                    </font>
                    <br /><br />
                	<font face="Arial" size="+2">
                    	<a href="http://www.mayatechnosoft.com/" target="_blank" style="text-decoration:none;">www.mayatechnosoft.com</a>
                    </font>
                    <br />
                    <font face="Arial" size="3" color="#E12301">
                    	IT Education For Everyone
                    </font>
              	</td>
            </tr>
            <tr align="center" bgcolor="#CC6600">
        		<td><font color="#FFFFFF" size="+1" face="Arial, Helvetica, sans-serif">Nehru Nagar, Opp. Jankidevi Jaiswal Convent, Nandanvan Main Road, Nagpur. Contact - +91 9028 430 942</font></td>
        </tr>
    </table>
    </body>
    </html>
    ';
    	
    	$msg_support = 'Client Details Are
                        <br /><br />
                        Name :- '.$name.'
                        <br />
                        Email :- '.$email.'
                        <br />
                        Phone :- '.$phone.'
                        <br />
                        Message :- '.$message.'
                    ';
    
    	$to_client = $email;
    	$to_support = '[removed]';
    	$from_support = 'Maya Technosoft - Details Received<noreply@mayatechnosoft.com>';
    	$subject_support = "Maya Technosoft - Details Received Successfully";
    	
    	$headers_support  = 'From:'.$from_support."\r\n";
    	$headers_support .= 'MIME-Version: 1.0' . "\r\n";
    	$headers_support .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    				
    	/****************************************Mail To support Team Ends***********************************************/
    	$p1 = mail($to_support, $subject_support, $msg_support, $headers_support);
    	$p2 = mail($email, $subject_support, $msg_client, $headers_support);
    	
    	if($p1 && $p2)
    	{
    		header("Location:contact-success.php");
    	}
    	else
    	{
    		header("Location:contact-fail.php");
    	}
    ?>
    Last edited by acoder; May 7 '13, 09:52 PM. Reason: Removed email address
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    Like the first warning says: PHP is failing to connect to the configured mail server. You need to make sure it is configured correctly so it can send the mail.

    We can't really tell you exactly what to change, because we don't know the details for whatever SMTP server you are trying to send the mail through.

    Comment

    Working...