PHPMailer Complications

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    PHPMailer Complications

    I can't seem to get it working with my smtp server.

    I can send the email through the command line like so:

    Code:
    220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Wed, 6 Aug 2008 18:44:29 -0600 
    EHLO www.dmconsultingonline.com 250-localhost.localdomain Hello mail.dmconsultingonline.com [x.x.x.x], pleased to meet you 250-ENHANCEDSTATUSCODES 
    250-PIPELINING 
    250-8BITMIME 
    250-SIZE 
    250-DSN 
    250-ETRN 
    250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN 
    250-DELIVERBY 
    250 HELP MAIL 
    FROM: dmurad@dmconsultingonline.com 
    250 2.1.0 dmurad@dmconsultingonline.com... Sender ok 
    RCPT TO: dmurad@dmconsultingonline.com 
    250 2.1.5 dmurad@dmconsultingonline.com... Recipient ok 
    DATA 
    354 Enter mail, end with "." on a line by itself 
    THIS IS A TEST email to dmurad 
    . 
    250 2.0.0 m770iTb2013039 Message accepted for delivery 
    QUIT 
    221 2.0.0 localhost.localdomain closing connection
    the message shows up fine in my outlook inbox.

    Note: in outlook I do have to set "My Outgoing server requires authentication"
    and it uses the same login as for POP.

    I know this makes a difference, but outlook doesn't tell you "technicall y" what difference that check mark makes.

    without this outlook doesn't connect to it.

    but, anyway:

    PHP Code (this is from example that comes with PHPMailer):

    [PHP]

    require_once("c onfig.php");

    $mail = new PHPMailer();

    $mail->IsSMTP(); // set mailer to use SMTP
    $mail->Host = "72.16.128. 45"; // specify main and backup server
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "dmurad"; // SMTP username
    $mail->Password = "connie02"; // SMTP password

    $mail->From = "dmurad@dmconsu ltingonline.com ";
    $mail->FromName = "Mailer";
    $mail->AddAddress("dm urad@dmconsulti ngonline.com");

    $mail->WordWrap = 50; // set word wrap to 50 characters
    $mail->IsHTML(true) ; // set email format to HTML

    $mail->Subject = "Here is the subject";
    $mail->Body = "This is the HTML message body <b>in bold!</b>";
    $mail->AltBody = "This is the body in plain text for non-HTML mail clients";

    if(!$mail->Send())
    {
    echo "<b>Message could not be sent. </b><p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    exit;
    }

    echo "Message has been sent";

    [/PHP]

    here's the output:

    Code:
    SMTP -> FROM SERVER: 
    SMTP -> FROM SERVER: 
    SMTP -> ERROR: EHLO not accepted from server: 
    SMTP -> FROM SERVER: 
    SMTP -> ERROR: HELO not accepted from server: 
    SMTP -> FROM SERVER: 
    SMTP -> ERROR: MAIL not accepted from server: 
    SMTP -> FROM SERVER: 
    SMTP -> ERROR: RSET failed: Message could not be sent.
    
    Mailer Error: The following From address failed: dmurad@dmconsultingonline.com
    I even tried it with SMTPAuth off/false.

    any clues?
  • Gulzor
    New Member
    • Jul 2008
    • 27

    #2
    Try this :
    [php]
    $PHPMailer->SMTPAuth = true;
    $PHPMailer->SMTPSecure = "ssl";
    [/php]

    Also, set $PHPMailer->Port with the correct port value if necessary.

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      Originally posted by Gulzor
      Try this :
      [php]
      $PHPMailer->SMTPAuth = true;
      $PHPMailer->SMTPSecure = "ssl";
      [/php]

      Also, set $PHPMailer->Port with the correct port value if necessary.
      I've tried that before, here's the output:

      Code:
      SMTP -> FROM SERVER: 
      SMTP -> FROM SERVER:  
      SMTP -> ERROR: EHLO not accepted from server:  
      SMTP -> FROM SERVER:  
      SMTP -> ERROR: HELO not accepted from server:  
      NULL 
      SMTP -> FROM SERVER: 
      SMTP -> ERROR: MAIL not accepted from server:  
      SMTP -> FROM SERVER: 
      SMTP -> ERROR: RSET failed:  <b>Message could not be sent. </b><p>Mailer Error: The following From address failed: dmurad@dmconsultingonline.com
      220 localhost.local domain ESMTP Sendmail 8.13.8/8.13.8; Thu, 7 Aug 2008 01:53:26 -0600
      EHLO localhost
      250-localhost.local domain Hello mydomain.com [x.x.x.x], pleased to meet you
      250-ENHANCEDSTATUSC ODES
      250-PIPELINING
      250-8BITMIME
      250-SIZE
      250-DSN
      250-ETRN
      250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
      250-DELIVERBY
      250 HELP
      AUTH LOGIN
      334 DijfexggbWU6
      ZG11cmFk229 UgFzc3c9dmQ6
      Y234TymllMDI=23 5 2.0.0 OK Authenticated
      MAIL FROM: myemail@hotmail .com
      250 2.1.0 myemail@hotmail .com... Sender ok
      RCPT TO: myemail@another host.com
      250 2.1.5 myemail@another host.com... Recipient ok
      DATA
      354 Enter mail, end with "." on a line by itself
      TESTING COMMAND LINE
      .
      250 2.0.0 m777rQNh014545 Message accepted for delivery
      QUIT
      221 2.0.0 localhost.local domain closing connection


      Connection to host lost.

      [/CODE]

      I got the email in my inbox just fine.

      Because of these complications, I decided to skip PHPMailer go directly to the source: class.smtp.php file it uses and see if I can get that to work.

      I'll post my code (i'm stuck there too) shortly...

      Comment

      • dlite922
        Recognized Expert Top Contributor
        • Dec 2007
        • 1586

        #4
        here you go:
        Code:
        require_once("smtp.php");
        
        
        echo "<pre>Start...";
        $smtp = new SMTP();
        $smtp->do_debug = 5;
        
        echo "\n\nConnecting...";
        var_dump($smtp->Connect("72.16.128.45","25")); 
        
        
        echo "\n\nEhlo...";
        $smtp->Hello(); 
        
        die();
        output is similar, So i guess if I solve this, i'll get to the root of the problem.



        Code:
        <pre>
        Start...  
        
        Connecting...
        SMTP -> FROM SERVER: bool(true)   
        
        Ehlo...
        SMTP -> FROM SERVER:  
        SMTP -> ERROR: EHLO not accepted from server:  
        SMTP -> FROM SERVER:  
        SMTP -> ERROR: HELO not accepted from server:  
        NULL
        Googling that thing is just a mess! Any help from mail server experts?

        Comment

        • dlite922
          Recognized Expert Top Contributor
          • Dec 2007
          • 1586

          #5
          here you go:

          Code:
          require_once("smtp.php");
          
          
          echo "<pre>Start...";
          $smtp = new SMTP();
          $smtp->do_debug = 5;
          
          echo "\n\nConnecting...";
          var_dump($smtp->Connect("72.16.128.45","25")); 
          
          
          echo "\n\nEhlo...";
          $smtp->Hello(); 
          
          die();
          
          // rest of my code if the above works, should work ...
          output is similar, So i guess if I solve this, i'll get to the root of the problem.


          OUTPUT:

          Code:
          <pre>
          Start...  
          
          Connecting...
          SMTP -> FROM SERVER: bool(true)   
          
          Ehlo...
          SMTP -> FROM SERVER:  
          SMTP -> ERROR: EHLO not accepted from server:  
          SMTP -> FROM SERVER:  
          SMTP -> ERROR: HELO not accepted from server:  
          NULL
          Googling that thing is just a mess! Any help from mail server experts?

          I even tried saying EHLO/HELO before connecting, same result.

          I'm just about ready to commit suicide guys, i'm at your mercy.


          Dan

          Comment

          • dlite922
            Recognized Expert Top Contributor
            • Dec 2007
            • 1586

            #6
            Originally posted by dlite922
            here you go:

            Code:
            require_once("smtp.php");
            
            
            echo "<pre>Start...";
            $smtp = new SMTP();
            $smtp->do_debug = 5;
            
            echo "\n\nConnecting...";
            var_dump($smtp->Connect("72.16.128.45","25")); 
            
            
            echo "\n\nEhlo...";
            $smtp->Hello(); 
            
            die();
            
            // rest of my code if the above works, should work ...
            output is similar, So i guess if I solve this, i'll get to the root of the problem.


            OUTPUT:

            Code:
            <pre>
            Start...  
            
            Connecting...
            SMTP -> FROM SERVER: bool(true)   
            
            Ehlo...
            SMTP -> FROM SERVER:  
            SMTP -> ERROR: EHLO not accepted from server:  
            SMTP -> FROM SERVER:  
            SMTP -> ERROR: HELO not accepted from server:  
            NULL
            Googling that thing is just a mess! Any help from mail server experts?

            I even tried saying EHLO/HELO before connecting, same result.

            I'm just about ready to commit suicide guys, i'm at your mercy.


            Dan
            Update:

            So that you're not blind, here's how the smtp class performs the helo commands:

            [PHP]

            /**
            * Sends a HELO/EHLO command.
            * @access private
            * @return bool
            */
            private function SendHello($hell o, $host) {
            fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);

            $rply = $this->get_lines();

            $code = substr($rply,0, 3);

            if($this->do_debug >= 2) {
            echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
            }

            if($code != 250) {
            $this->error =
            array("error" => $hello . " not accepted from server",
            "smtp_code" => $code,
            "smtp_msg" => substr($rply,4) );
            if($this->do_debug >= 1) {
            echo "SMTP -> ERROR: " . $this->error["error"] .
            ": " . $rply . $this->CRLF;
            }
            return false;
            }

            $this->helo_rply = $rply;

            return true;
            }


            [/PHP]

            it almost looks like $rply is blank, but fputs() writes about 16 bytes.

            I'll try to debug get_lines().

            Comment

            • Gulzor
              New Member
              • Jul 2008
              • 27

              #7
              We use PHPMailer in several projects and we never have that kind of issues. But we like to keep things simple.

              Do you use the last version of PHPMailer ? Are you sure that your SMTP server is configured correctly ?

              That is weird.

              Comment

              • dlite922
                Recognized Expert Top Contributor
                • Dec 2007
                • 1586

                #8
                Originally posted by Gulzor
                We use PHPMailer in several projects and we never have that kind of issues. But we like to keep things simple.

                Do you use the last version of PHPMailer ? Are you sure that your SMTP server is configured correctly ?

                That is weird.
                Hey thanks for the quick reply.

                The issue wasn't related to PHPMailer or any PHP issue.

                I noticed a couple of times the page would just stall and consume 100% CPU.

                So I rebooted it all apache processes and voila! fixed itself.

                Everything started working, my script and the PHP Mailer script.

                And yes I did grab the latest version.

                Don't you hate it when that happens. freakin Windows!!

                ugh!!! I'm a day and a half behind in a project.

                but damn at least I can sleep tonight.

                thanks by the way,



                Dan

                Comment

                Working...