Jump to content


Photo

Can't send mail using mail()


  • Please log in to reply
2 replies to this topic

#1 tanveer

tanveer
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 16 June 2006 - 05:09 AM

Hi all:
I am facing a strange problem here.
I developed a small application where after filling up a form when users press SUBMIT button then an auto mail will be sent to an address locally. We are under a windows domain say, abc.com.

There are two types of address, those who are using internet to send receive mail from both locally and from outside address (like yahoo) is <username@abc.com.bd> and others only can send-receive mail locally is <username@abc.com>.
Both type of users can easily send-receive mails between them.

So, I just edited these two lines of php.ini file
[php.ini]
SMTP = xyz.abc.com.bd // gave our smtp server name
sendmail_from = "tanveer@abc.com.bd" // my email address

So after changing I restarted the apache server and sent mail. But after that one time I cant send mails anymore.
It gives a warning like: Can't receive in ..... in line 5.
That is the line where the mail() function is written. But that same file, if I upload it in our webserver then it works fine.

What could be the problem?
Thanks in advance.




#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 16 June 2006 - 07:39 AM

can you post the actual code
z..z..z..z..z..z..z..z..

#3 tanveer

tanveer
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 16 June 2006 - 09:06 AM

thanks for your reply.
feedback.htm
<form name="feedback" method="post" action="feedback.php">
                    
        <table width="610" height="249" style="border:0px solid #b4b4b4" cellspacing="0" cellpadding="0" align="left">
        <tr>
          <td width="38%" height="29"><div align="left"><img src="images/feedback.jpg" width="215" height="22">
          </div></td>
          <td width="62%"> </td>
        </tr>
        <tr class="style5">
          <td height="24"><span class="style13"> Name </span></td>
          <td><input type="text" name="name" value="" maxlength="35" style="border:1px solid #000000"></td>
        </tr>
        <tr class="style5">
          <td height="24"><span class="style13">Telephone</span></td>
          <td><input type="text" name="telephone" value="" maxlength="35" style="border:1px solid #000000"></td>
        </tr>
         <tr class="style5">
          <td height="24"><span class="style13">Email</span></td>
          <td><input type="text" name="email" value="" maxlength="35" style="border:1px solid #000000"></td>
        </tr>
         <tr class="style5">
          <td height="24"><span class="style13">Comments</span></td>
          <td><textarea name="comments"  style="border:1px solid #000000"></textarea></td>
        </tr>
        <tr class="style5">
          <td height="17"> </td>
          <td> </td>
        </tr>
        <tr class="style5">
          <td align="center" height="35"><input type="submit" value="Submit" name="submit"></td>
          <td align="left"><input type="reset" value="Reset" name="reset"></td>
        </tr>
        <tr class="style5">
          <td height="24" colspan="2" align="center"><img src="images/div.jpg" width="611" height="19"></td>
      </tr>
      </table>      
      </form>

feedback.php
<?php
  if ( empty($_POST[email]) || empty ($_POST[name])|| empty ($_POST[comments]))
    {

       if (empty($_POST[email]))  echo "<center><b> Email address is a required field </b></center>";
       if (empty($_POST[name]))  echo "<center><b> Name is a required field </b></center>";
       if (empty($_POST[comments]))  echo "<center><b> Comments is a required field </b></center>";

       }

else {

$from=$_POST[email];

$headers= "From: $from \r\n";
$headers .= "MIME-Version:1.0\n" . "Content-type: text/html; charset=iso-8859-1";

mail ("tanveer@abc.com.bd","Website Feedback",$_POST[comments], $headers);

echo "YOUR COMMENTS HAS BEEN SUCCESSFULLY SUBMITTED TO THE WEBMASTER";

}
?>

The same code will work if I upload it to the webserver using ftp.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users