Sendmail sends email to all domains but for one

Discussion in 'PHP' started by slax, Aug 30, 2010.

  1. slax

    slax New Member

    Joined:
    Aug 30, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Dear All,

    We have a php website... where we used a simple email form to send feedback from users visiting website. our website is hosted on bluehost.com hosting.

    the email form sends email to any email address, like gmail, other domains but for our corporate email address.

    to understand this, i moved the code to linux box and tested the email form... and the results are the same.

    suspecting the code might be wrong, i made a simple email form and tested the same, and the results are again the same.

    later, checked with network admin if the emails are blocked, there are no emails which are blocked. [our network setup: websense + MS Exchange]

    can someone suggest any solution for this.

    - slax
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    If the email is not being delivered on one particular email address there are chances that it is being blocked on the receiving end but you can still see your outgoing email queue to see if it is being dispatched and if it is then there is nothing much you need to be doing it.
     
  3. slax

    slax New Member

    Joined:
    Aug 30, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hey shabbir,

    well even i was thinking the same, but surprisingly, the email works in telnet... which is shocking.

    - slax
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Interesting and there may be some other factors like boxbe being used by that email address.
     
  5. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    to be clear:

    when you use php script you dont recieve the mail to your own host (but recieved by other hosts?)
    when you use telnet everythin works fine?

    im not sure but is your pop working OK?
    i mea may be a little chance of having a misconfig cuz if gmail n other POPULAR sewrvices can recieve there can hardly be a fault in code
     
  6. slax

    slax New Member

    Joined:
    Aug 30, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Interesting and there may be some other factors like boxbe being used by that email address.

    well, our network is using... Websense Web Filter Solutions [websense.com/content/WebFilter.aspx] &
    Websense Hosted Email Security [websense.com/content/HostedEmailSecurity.aspx] and we have microsoft exchange server 2007.

    Emails generated from the script are not seen on websense tool. I have already forwarded the request to the exchange server people to check if it is blocked at there end... but i highly doubt it as all emails are passed through websense first and then to microsoft exchange server.

    when you use php script you dont recieve the mail to your own host (but recieved by other hosts?)

    yea, thats right... it works for gmail [goes to inbox not spam], yahoo, other popular hosts, also sent to my friends who work at big IT firms, even they recieved it.

    when you use telnet everythin works fine?

    well telnet works.. check below

    ----telnet----
    Code:
    root@webuat-it:/home/webroot# telnet 172.16.1.24 25
    Trying 172.16.1.24...
    Connected to 172.16.1.24.
    Escape character is '^]'.
    220 comp-BLR-EHC02 Microsoft ESMTP MAIL Service ready at Tue, 31 Aug 2010 09:18:32 +0530
    helo 172.16.1.24
    250 comp-BLR-EHC02 Hello [172.18.3.212]
    mail from:myemail@mydomain.com
    250 2.1.0 Sender OK
    rcpt to: myemail@mydomain.com
    250 2.1.5 Recipient OK
    data
    354 Start mail input; end with <CRLF>.<CRLF>
    subject: testing 123
    to: myemail@mydomain.com
    test mail 123 
    .
    250 2.6.0 <d302adbf-b823-4dc8-9063-a2530f1a4528@comp-BLR-EHC02.mydomain.local> Queued mail for delivery
    quit 
    221 2.0.0 Service closing transmission channel
    Connection closed by foreign host. 
    
    im not sure but is your pop working OK?

    is pop required ? i havent checked it yet... since the email delivery happens to all email addresses... i dint concentrate on this.

    i mea may be a little chance of having a misconfig cuz if gmail n other POPULAR sewrvices can recieve there can hardly be a fault in code

    yea i know, the website had multiple email feedback form and none of them were working, suspecting the fault in code... i made a simple php email form.... and results are same....

    check the file below:
    send_form_email.php
    Code:
    <?php
    if(isset($_POST['email'])) {
       
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "myemail@mydomain.com, myemail@gmail.com, mycollegueemail@mydomain.com, admin@externaldomainusinggoogleapps.com, mycollegueemail@mydomain.com, friendsemail@emailoftop10-it-firm.com";
    
        $email_subject = "Test Mail ";
       
       
        function died($error) {
            // your error code can go here
            echo "We are very sorry, but there were error(s) found with the form your submitted. ";
            echo "These errors appear below.<br /><br />";
            echo $error."<br /><br />";
            echo "Please go back and fix these errors.<br /><br />";
            die();
        }
       
        // validation expected data exists
        if(!isset($_POST['first_name']) ||
            !isset($_POST['last_name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['telephone']) ||
            !isset($_POST['comments'])) {
            died('We are sorry, but there appears to be a problem with the form your submitted.');       
        }
       
        $first_name = $_POST['first_name']; // required
        $last_name = $_POST['last_name']; // required
        $email_from = $_POST['email']; // required
        $telephone = $_POST['telephone']; // not required
        $comments = $_POST['comments']; // required
       
        $error_message = "";
        $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
      if(!eregi($email_exp,$email_from)) {
          $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
      }
        $string_exp = "^[a-z .'-]+$";
      if(!eregi($string_exp,$first_name)) {
          $error_message .= 'The First Name you entered does not appear to be valid.<br />';
      }
      if(!eregi($string_exp,$last_name)) {
          $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
      }
      if(strlen($comments) < 2) {
          $error_message .= 'The Comments you entered do not appear to be valid.<br />';
      }
      $string_exp = "^[0-9 .-]+$";
      if(!eregi($string_exp,$telephone)) {
          $error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
      }
      if(strlen($error_message) > 0) {
          died($error_message);
      }
        $email_message = "Form details below.\n\n";
       
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        }
       
        $email_message .= "First Name: ".clean_string($first_name)."\n";
        $email_message .= "Last Name: ".clean_string($last_name)."\n";
        $email_message .= "Email: ".clean_string($email_from)."\n";
        $email_message .= "Telephone: ".clean_string($telephone)."\n";
        $email_message .= "Comments: ".clean_string($comments)."\n";
       
       
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers); 
    ?>
    
    <!-- include your own success html here -->
    
    Thank you for contacting us. We will be in touch with you very soon. test
    
    <?
    }
    ?>
    
    emailform.html
    Code:
    <form name="contactform" method="post" action="send_form_email.php">
    <table width="450px">
    </tr>
    <tr>
     <td valign="top">
      <label for="first_name">First Name- *</label>
     </td>
     <td valign="top">
      <input  type="text" name="first_name" maxlength="50" size="30">
     </td>
    </tr>
    
    <tr>
     <td valign="top"">
      <label for="last_name">Last Name *</label>
     </td>
     <td valign="top">
      <input  type="text" name="last_name" maxlength="50" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="email">Email Address *</label>
     </td>
     <td valign="top">
      <input  type="text" name="email" maxlength="80" size="30">
     </td>
    
    </tr>
    <tr>
     <td valign="top">
      <label for="telephone">Telephone Number</label>
     </td>
     <td valign="top">
      <input  type="text" name="telephone" maxlength="30" size="30">
     </td>
    </tr>
    <tr>
     <td valign="top">
      <label for="comments">Comments *</label>
     </td>
     <td valign="top">
      <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
     </td>
    
    </tr>
    <tr>
     <td colspan="2" style="text-align:center">
      <input type="submit" value="Submit">  
     </td>
    </tr>
    </table>
    </form>
    
     
  7. kien_vn

    kien_vn New Member

    Joined:
    Aug 31, 2010
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Some business mail server use spam filter application , so your email was killed when reach partner mail server
     
  8. slax

    slax New Member

    Joined:
    Aug 30, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hi kien,

    i checked with the spam filters ... there is no blocking there... as i can understand, mydomain is not getting resolved from my UAT.. check this out

    Code:
    root@webuat:/home/webroot# dig mydomain.com
    
    ; <<>> DiG 9.7.0-P1 <<>> mydomain.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50441
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;mydomain.com.			IN	A
    
    ;; ANSWER SECTION:
    mydomain.com.		1374	IN	A	166.17.22.18
    
    ;; Query time: 0 msec
    ;; SERVER: 172.18.0.71#53(172.18.0.71)
    ;; WHEN: Mon Sep  6 12:14:06 2010
    ;; MSG SIZE  rcvd: 46
    
    root@webuat:/home/webuat# sendmail -bv myusername@mydomain.com
    myusername@mydomain.com... User unknown
    
     
  9. slax

    slax New Member

    Joined:
    Aug 30, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    how do i look into the this issue.... of domain not able to resolve.

    kindly let me know where to start... i have been stuck with this issue for so long now...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice