By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,602 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,602 IT Pros & Developers. It's quick & easy.

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

P: 10
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\cateringcom\contactprocess .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\cateringcom\contactprocess .php on line 79

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


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $name=$_POST['name'];
  3.     $email=$_POST['email'];
  4.     $phone=$_POST['phone'];
  5.     $message=$_POST['message'];
  6.  
  7.     // multiple recipients
  8.     $to_client  = $email;
  9.     $to_admin  = '[removed]';
  10.  
  11.     // subject
  12.     $subject = 'Maya Technosoft - Details Received Successfully';
  13.  
  14.     // message
  15.     $msg_client = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19. <title>Untitled Document</title>
  20. </head>
  21.  
  22. <body>
  23. <table width="100%" cellpadding="5" cellspacing="5">
  24.     <tr align="center" bgcolor="#CC6600">
  25.         <td><font color="#FFFFFF" size="+3" face="Arial, Helvetica, sans-serif">MAYA TECHNOSOFT</font></td>
  26.     </tr>
  27.     <tr align="center">
  28.         <td><font face="Arial, Helvetica, sans-serif" color="#CC6600" size="+2">Thank You '.$name.' Your Details Received Successfully</font></td>
  29.     </tr>
  30.     <tr>
  31.                  <td align="center" bgcolor="#F3F2F2">
  32.                   <font face="Arial" size="3" color="#E12301">
  33.                     This is the confirmation email that we have received your detail successfully. Our support team member will contact you shortly. 
  34.                 </font>
  35.                 <br /><br />
  36.                 <font face="Arial" size="2" color="#E12301">
  37.                     Please do not reply this email, as this is an auto generated email.
  38.                 </font>
  39.                 <br /><br />
  40.                 <font face="Arial" size="+2">
  41.                     <a href="http://www.mayatechnosoft.com/" target="_blank" style="text-decoration:none;">www.mayatechnosoft.com</a>
  42.                 </font>
  43.                 <br />
  44.                 <font face="Arial" size="3" color="#E12301">
  45.                     IT Education For Everyone
  46.                 </font>
  47.               </td>
  48.         </tr>
  49.         <tr align="center" bgcolor="#CC6600">
  50.             <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>
  51.     </tr>
  52. </table>
  53. </body>
  54. </html>
  55. ';
  56.  
  57.     $msg_support = 'Client Details Are
  58.                     <br /><br />
  59.                     Name :- '.$name.'
  60.                     <br />
  61.                     Email :- '.$email.'
  62.                     <br />
  63.                     Phone :- '.$phone.'
  64.                     <br />
  65.                     Message :- '.$message.'
  66.                 ';
  67.  
  68.     $to_client = $email;
  69.     $to_support = '[removed]';
  70.     $from_support = 'Maya Technosoft - Details Received<noreply@mayatechnosoft.com>';
  71.     $subject_support = "Maya Technosoft - Details Received Successfully";
  72.  
  73.     $headers_support  = 'From:'.$from_support."\r\n";
  74.     $headers_support .= 'MIME-Version: 1.0' . "\r\n";
  75.     $headers_support .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
  76.  
  77.     /****************************************Mail To support Team Ends***********************************************/
  78.     $p1 = mail($to_support, $subject_support, $msg_support, $headers_support);
  79.     $p2 = mail($email, $subject_support, $msg_client, $headers_support);
  80.  
  81.     if($p1 && $p2)
  82.     {
  83.         header("Location:contact-success.php");
  84.     }
  85.     else
  86.     {
  87.         header("Location:contact-fail.php");
  88.     }
  89. ?>
May 7 '13 #1
Share this Question
Share on Google+
1 Reply


Atli
Expert 5K+
P: 5,058
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.
May 7 '13 #2

Post your reply

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