6 Replies - 3605 Views - Last Post: 05 March 2013 - 10:18 PM

#1 vindyauwu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-March 13

Not sending Mails in Live server

Posted 04 March 2013 - 04:20 AM

Mails not sending in Live server but it works fine in demo server.Here is the code..



<!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">

<?php include('header.php'); ?>



      

<body id="enquery">



<div class="main">

<div class="frame_wrapper">

<div class="wrapper" id="coporate">

<div class="welcome" id="coporate">
<div class="link">

<a href="enquire.php"style="color:#FF0;">Enquiry</a>|<a href="contact.php">Contact</a>

</div>
<h1>Enquiries</h1>

<?php

include('conect_db.php');

	$intro = mysql_query("select * from intropage where id = '2'");

	$cmintro = @mysql_fetch_assoc($intro);

	$enqIntro = $cmintro['contents'];

	

	echo $enqIntro;



?>







<?php 



$to = 'mail@sun-signature.com';



if(!empty($_POST['title'])  ||

   !empty($_POST['fname']))

{





$title=$_POST['title'];

$fname=$_POST['fname'];

$lname=$_POST['lname'];

$company=$_POST['company'];

$eaddrs=$_POST['eaddrs'];

$contactno=$_POST['contactno'];

$address=$_POST['address'];

$enquiery=$_POST['enquiery'];

$message=$_POST['message'];



// validate a phone number

$msg  = "Title : $title \r\n\n";

$msg .= "FirstName : $fname \r\n\n";

$msg .= "LastName : $lname \r\n\n";

$msg .= "Company : $company \r\n\n";

$msg .= "Email: $eaddrs \r\n\n";

$msg .= "ContactNo : $contactno\r\n\n";

$msg .= "Address : $address \r\n\n";

$msg .= "Enquiery : $enquiery \r\n\n";

$msg .= "Message : $message\r\n\n";



}

?> 







<?php

						   if ($_SERVER['REQUEST_METHOD'] != 'POST'){

							  $self = $_SERVER['PHP_SELF'];

						?> 

                        

<form method='post' action='<?php echo $self;?>'>

<table class="enq" width="958" border="0">

  <tr>

    <td width="703">

    

    <table width='100%' class='inq'>

	<tr>

		<td>Title*</td>

		<td>

		<select name='title'>

		<option value=''>Please Select Title</option>

		<option value='Mr'>Mr</option>

		<option value='Mrs'>Mrs</option>

		<option value='Ms'>Ms</option>

		<option value='Mr'>Mdm</option>

		<option value='Mr'>Dr</option>

		</select>

		</td>

	</tr>

	<tr>

		<td>First Name*</td>

		<td><input type='text' name='fname' size='40'></td>

	</tr>

	<tr>

		<td>Last Name*</td>

		<td><input type='text' name='lname' size='40'></td>

	</tr>

	<tr>

		<td>Company*</td>

		<td><input type='text' name='company' size='40'></td>

	</tr>

	<tr>

		<td>Email Address*</td>

		<td><input type='text' name='eaddrs' size='40'></td>

	</tr>

	<tr>

		<td>Contact No*</td>

		<td><input type='text' name='contactno' size='40'></td>

	</tr>

	<tr>

		<td>Address</td>

		<td><input type='text' name='address' size='40'></td>

	</tr>

	<tr>

		<td>Enquiry Type*</td>

		<td>

		<select name='enquiery'>

		<option value=''>Please Select Title</option>

		<option value='General Information'>General Information</option>

		<option value='Events and Media'>Events and Media</option>

		<option value='Business opportunities'>Business opportunities</option>

		<option value='Bulk orders/wholesale'>Bulk orders/wholesale</option>

		<option value='Others'>Others</option>

		</select>

		</td>

	</tr>

	<tr>

		<td valign='top'>Message*</td>

		<td><textarea name='message' cols='31' rows='5'></textarea></td>

	</tr>

	<tr>

		<td valign='top'>&nbsp;</td>

		<td><input type='submit' name='submit1' class='submit1' value='Submit'></td>

	</tr>

</table>

    

    

    	</tr>

</table>



</form>



							<?php 	} else {

									error_reporting(0);

							

									if  (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))

									echo nl2br("

									<ul class=\"MsgSent\">

										<h4>Congratulations!!</h4>

										<p>Thank you, your message is sent!<br /> We will get back to you as soon as possible.</p>

									</ul>

								   ");

							

									else

									echo "

									<ul class=\"MsgError\">

										<h1>Error!!</h1>

										<p>Sorry, your message failed to send. Try later!</p>

							</ul>";

								}  

							?>



</div>





</div>

</div>



 <?php include('nav1.php'); ?> 

</div>



<?php include('footer.php'); ?>



</body>

</html>







Is This A Good Question/Topic? 0
  • +

Replies To: Not sending Mails in Live server

#2 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5305
  • View blog
  • Posts: 27,198
  • Joined: 10-May 07

Re: Not sending Mails in Live server

Posted 04 March 2013 - 06:53 AM

The mail() command is rather straight forward. If it works on one server & not on another, then the problem is not with your code.

Who setup these servers? You are going to need to be 100% sure that the php.ini is replicated & that your isp allows mail to be sent on port 25, & all of that fun troubleshooting.

** Moving to webservers & hosting, because this is not an issue with php code **
Was This Post Helpful? 0
  • +
  • -

#3 vindyauwu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-March 13

Re: Not sending Mails in Live server

Posted 04 March 2013 - 08:46 PM

thanks lot for your reply..Server if from our client side..I checked their SMTP it on localhost and port is 25 do i need to tell them to change it?
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5305
  • View blog
  • Posts: 27,198
  • Joined: 10-May 07

Re: Not sending Mails in Live server

Posted 04 March 2013 - 08:51 PM

smtp by default is set to port 25. However if no mail is setup on localhost, it isn't going to send.
Was This Post Helpful? 0
  • +
  • -

#5 vindyauwu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-March 13

Re: Not sending Mails in Live server

Posted 05 March 2013 - 01:11 AM

so, how can i fix it?is there any way?
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5305
  • View blog
  • Posts: 27,198
  • Joined: 10-May 07

Re: Not sending Mails in Live server

Posted 05 March 2013 - 07:04 AM

This can not be fixed with php.

As I previously stated, you will not know what the problem is without looking at the logs.

You need to know : (both live & test servers)

a.) What smtp software is running, sendmail, qmail, etc. Look up their documentation, & read the software's logging output.
b.) What ip address both servers are running on : For example are they both in the same building on the same isp, or did you test one at home & one at the office?
c.) Does the isp that is failing even allow traffic on port 25?

Your answer will be in the logs. But I don't have access to them, so I can't decipher what is wrong & explain to you how to fix it.

To make your situation more clear, read the php.net manual on the mail() command. It doesn't actually transfer the email. It returns true or false if the mail command was called. There is a bunch of automagic processing that takes place in the background. That is where your problem is. However to better understand exactly where the issue is, you have some homework to do by gathering as much information about your setup as possible, & then armed with that knowledge you can better attack the situation.
Was This Post Helpful? 0
  • +
  • -

#7 vindyauwu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-March 13

Re: Not sending Mails in Live server

Posted 05 March 2013 - 10:18 PM

Thank you very much for your reply..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1