Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Mailer SMTP failing?

edited June 2012 in Framework

I have tried everything to get elefant to pass email through SMTP. Nothing is working (Neither mandrill nor google smtp servers.)

I even tried building a hard coded sending into the mailer and it fails on the new Zend_Mail_Transport_Smtp()

require_once ('Zend/Mail/Transport/Smtp.php');
$config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => 'user@gmail.com', 'password' => 'xxxxxx');
$smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

            $mail = new Zend_Mail();
            $mail->setBodyText('This is the text of the mail.');
            $mail->setFrom('user@gmail.com', User');
            $mail->addTo('reeiever@gmail.com', 'Reciever');
            $mail->setSubject('TestSubject');
            $mail->send($smtpConnection);

I have no idea what's going on, the server simply fails.

Comments

  • Ugh. Screw it. I am tired of messing with this, I am just re-factoring my entire mailer to use mandrill/mailchimp api.

  • Well... SwiftMailer it is. I was able to get that up and running in no time. No idea what the heck is up with Zend.

    Although I just realized how easy it is for elefant to send personalized html template emails... yay! Pretty emails for me!

  • Tried port 80 instead of 587 as a test? I've had that issue before.

  • I tried 80, 587, 465, 25 tls ssl

    Everything. It was awesome. Then I just rewrote it to use swiftmailer and everything worked fine.

  • Hmm, I chose Zend after doing some tests and seeing that it was way faster and lower memory than Swift, but if it doesn't work then that means nothing. I'm away again tomorrow for a week, but after that I've got this on my list to test out.

    Also really pining for some time to get into a few other Elefant to do items... :)

  • Yeah. I know you did, I read through the benchmarks which was why I was trying to get it working. I may visit back to it again when I have time. The issue seemed to popup when I tried to enable login authentication.

  • Indeed, and it seems to be happening in the send() method of Zend_Mail. Even wrapping it in a try/catch doesn't help, just kills the request with no error output or logged notice :\

  • edited July 2012

    Pretty much. Which is why I got pissed and switched to SwiftMailer. I even tried to implement using nothing but the Zend Library outside of elefant and nothing worked. I eventually got it down to where I was getting some file dependency issues and eventually just gave up.

  • I think you just pointed me to the issue: Missing Zend/Loader.php file in lib/vendor. I found a reference to it in Zend_Mail_Transport_Smtp::_sendMail() and sure enough, adding it got Gmail's SMTP working.

    From there I was able to set the following in conf/config.php:

    email_from = "me@gmail.com"
    email_name = First Last
    transport[type] = smtp
    transport[host] = smtp.gmail.com
    transport[ssl]  = tls
    transport[port] = 587
    transport[auth] = login
    transport[username] = "me@gmail.com"
    transport[password] = "********"
    

    Then in a test handler this worked no problem:

    <?php
    
    try {
        $mail = Mailer::send (array (
            'to' => array ('test@gmail.com', 'Another Account'),
            'subject' => 'Testing SMTP',
            'text' => 'This is a plain text test message.'
        ));
    } catch (Exception $e) {
        echo $e->getMessage ();
    }
    
    ?>
    

    I'll commit the missing file in ~30 seconds :)

  • Hi. I was trying to implement this Mandrill using same methods "short" showed in the first example. It should be pretty simple but what I'm getting from Mandrill is "authentication failed". I'm using exactly the correct login + generated the KEY and correct port. Any idea what can be wrong?

  • Hmm, it looks like one problem was the autoloader not correctly translating Zend_Mail_Protocol_Smtp_Auth_Plain class names to file paths. Just checked in a fix for this:

    https://github.com/jbroadway/elefant/commit/795a553f34d71e64bf34175b69d594b8d36dbed0

    Also just signed up for Mandrill and setting up a test for it here.

  • Looks like the following settings in conf/config.php's [Mailer] section worked for me:

    transport[type] = smtp
    transport[host] = smtp.mandrillapp.com
    transport[name] = mandrill
    transport[ssl] = ssl
    transport[port] = 465
    transport[auth] = plain
    transport[username] = USERNAME
    transport[password] = API_KEY
    

    Just replace the USERNAME and API_KEY with the values from Mandrill and it should work for you.

Sign In or Register to comment.