Zend Mail smtp transport

souvik2008 used Ask the Experts™
Hello Experts,

I am struck in a position that I really need your help to move forward. I have a program whihc sends weekly newsletter via Zend mal smpt transport to about 2000 coustomers. At first in one hosting server it was working fine. But when I migrate it to a diifferent web server and configured the email accounts there. It stopped working . I get an error here with

Could not open socket .

My code which sends the mail is as follows. the same code worked before.
protected function sendNewsletter($from, $subject, $body) {
		$config = array('auth' => 'login',
                'username' => 'contact@piano-sheets.net',
                'password' => 'pass',
				'port' => 25);
		$transport = new Zend_Mail_Transport_Smtp('mail.piano-sheets.net', $config);
        $mail = new Zend_Mail();
        //$mail->addTo($from, $from);
        $mail->setFrom($from, 'Piano-Sheets');		
        $model = $this->_getMailingListModel();
        $mails = $model->findAll();
        if($mails == null)
        $counter = 0;
        $sent = 0;
        //echo $body;
        foreach($mails as $mailAdress) {
			if ($this->check_email_address($mailAdress['mailing_mail'])) {
				//print $email . ' is a valid email address.';
			} else {
				//print $mailAdress . ' is not a valid email address.';
            if($sent == count($mails)) {
            if($counter == 100 || $sent == count($mails)) {
                try {
                } catch (Zend_Mail_Transport_Exception $e) {
                    //print $e;
                    // Do something here, mail failed to send
                //echo $mail->getRecipients();
                $counter = 0;
		$this->_response->appendBody(Zend_Json::encode("SUCCESS: Sending mail finished. Newsletter sent on " . count($mails) . " mails! "));		

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Your script is trying to send the mail to "mail.piano-sheets.net" to have that MTA deliver it to all your recipients. That name doesn't resolve to an IP address:

# host mail.piano-sheets.net
Host mail.piano-sheets.net not found: 3(NXDOMAIN)

Maybe that's a "private" name only accessible from certain dns servers, can you try doing via IP address to that server instead? Or try a different relay, your webhosting company will have a mail relay setup for it's webhost customers to use just for these kinds of things.
Sudeep SharmaTechnical Designer


Probably your new web server is already running another MTA and hence you are not able to open port 25 with your application to send the email out. If that MTA is not working for anything stop it and then it should work fine.

I hope that would help



Thank you so much.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial