Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 29-04-2010 16:11:51

maryooman
Membre
Date d'inscription: 15-02-2010
Messages: 106

[ZF 1.10.3][Zend_Mail]Envoi Mail

Bonjour,

C'est un sujet abordé plusieurs fois, mais le code, malgré qu'il soit minimaliste ne fonctionne pas.

Il y a même beaucoup de sujets sur internet.
http://stackoverflow.com/questions/7369 … oogle-apps
Celui là ce termine sur un blocage (il est plutôt enceint)
http://zend-framework-community.634137. … 44165.html

1) J'envoie par gmail

Code:

            $config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => 'truc@gmail.com', 'password' => '***');
            $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

            $mail = new Zend_Mail('utf-8');
            $mail->setSubject('Sujet de test');
            $mail->setFrom('uneadresse');
            $mail->addTo('uneadresse');
            $mail->setBodyText('Ceci est un test de la fonction mail de Zend Framework');
            $mail->send($transport);

Résultat

Application error
Exception information:
Message: Unable to connect via TLS
Stack trace:
#0 C:\wamp\www\test\library\Zend\Mail\Transport\Smtp.php(200): Zend_Mail_Protocol_Smtp->helo('localhost')
#1 C:\wamp\www\test\library\Zend\Mail\Transport\Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail()
#2 C:\wamp\www\test\library\Zend\Mail.php(1178): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#3 C:\wamp\www\test\application\views\scripts\index\index.phtml(157): Zend_Mail->send(Object(Zend_Mail_Transport_Smtp))
#4 C:\wamp\www\test\library\Zend\View.php(108): include('C:\wamp\www\Net...')
#5 C:\wamp\www\test\library\Zend\View\Abstract.php(880): Zend_View->_run('C:/wamp/www/Net...')
#6 C:\wamp\www\test\library\Zend\Controller\Action\Helper\ViewRenderer.php(897): Zend_View_Abstract->render('index/index.pht...')
#7 C:\wamp\www\test\library\Zend\Controller\Action\Helper\ViewRenderer.php(918): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', NULL)
#8 C:\wamp\www\test\library\Zend\Controller\Action\Helper\ViewRenderer.php(957): Zend_Controller_Action_Helper_ViewRenderer->render()
#9 C:\wamp\www\test\library\Zend\Controller\Action\HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#10 C:\wamp\www\test\library\Zend\Controller\Action.php(523): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#11 C:\wamp\www\test\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#12 C:\wamp\www\test\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#13 C:\wamp\www\test\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#14 C:\wamp\www\test\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#15 C:\wamp\www\test\public\index.php(26): Zend_Application->run()
#16 {main} 
Request Parameters:
array (
  'controller' => 'index',
  'action' => 'index',
  'id' => '2',
  'module' => 'default',
)

2) J'envoi par un smtp privé
Il n'y a pas de mot de passe ni de cryptage

Code:

            $config = array('auth' => 'login',
                                'port'     => 25,
                                'username' => 'truc@truc.com'
                );
            $transport = new Zend_Mail_Transport_Smtp('smtp1.truc.truc.com', $config);

            $mail = new Zend_Mail('utf-8');
            $mail->setSubject('Sujet de test');
            $mail->setFrom('uneadresse');
            $mail->addTo('uneadresse');
            $mail->setBodyText('Ceci est un test de la fonction mail de Zend Framework');
            $mail->send($transport);

Résultat

Application error
Exception information:
Message: 5.5.1
Stack trace:
#0 C:\wamp\www\test\library\Zend\Mail\Protocol\Smtp\Auth\Login.php(91): Zend_Mail_Protocol_Abstract->_expect(334)
#1 C:\wamp\www\test\library\Zend\Mail\Protocol\Smtp.php(217): Zend_Mail_Protocol_Smtp_Auth_Login->auth()
#2 C:\wamp\www\test\library\Zend\Mail\Transport\Smtp.php(200): Zend_Mail_Protocol_Smtp->helo('localhost')
#3 C:\wamp\www\test\library\Zend\Mail\Transport\Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail()
#4 C:\wamp\www\test\library\Zend\Mail.php(1178): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#5 C:\wamp\www\test\application\controllers\IndexController.php(50): Zend_Mail->send(Object(Zend_Mail_Transport_Smtp))
#6 C:\wamp\www\test\library\Zend\Controller\Action.php(513): IndexController->indexAction()
#7 C:\wamp\www\test\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#8 C:\wamp\www\test\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#9 C:\wamp\www\test\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#10 C:\wamp\www\test\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#11 C:\wamp\www\test\public\index.php(26): Zend_Application->run()
#12 {main} 
Request Parameters:
array (
  'controller' => 'index',
  'action' => 'index',
  'id' => '2',
  'module' => 'default',
)

Voilà, même ce petit boue de code me bloque ...

Hors ligne

 

#2 29-04-2010 16:43:48

shadypierre
Membre
Date d'inscription: 24-03-2010
Messages: 617

Re: [ZF 1.10.3][Zend_Mail]Envoi Mail

Moi j'ai simplement config mon php.ini avec le smtp de mon fournisseur (soit : smtp.free.fr) et ça marche nickel

Hors ligne

 

#3 29-04-2010 17:12:21

maryooman
Membre
Date d'inscription: 15-02-2010
Messages: 106

Re: [ZF 1.10.3][Zend_Mail]Envoi Mail

mais les mail que tu envoies, sortent de la boite free je suppose.

ou bien tu me dis que je dois choisir le smtp de mon FAI ? C'est étrange, car si j'envoie en gmail alors c'est le smtp de gmail.

Dernière modification par maryooman (29-04-2010 17:32:14)

Hors ligne

 

#4 30-04-2010 09:24:11

maryooman
Membre
Date d'inscription: 15-02-2010
Messages: 106

Re: [ZF 1.10.3][Zend_Mail]Envoi Mail

1)Je suis en localhost avec wamp, mais sur un pc distant avec wamp c'est pareil.


2)Quelqu'un à un code avec le smtp configuré, pour yahoo, ou hotmail par exemple ? (comme gmail ne semble pas fonctionner avec zend_mail). Ce n'ai pas logique que la classe Mail soit déféctueuse!

Hors ligne

 

#5 30-04-2010 18:14:24

throrin19
Membre
Date d'inscription: 01-03-2009
Messages: 318
Site web

Re: [ZF 1.10.3][Zend_Mail]Envoi Mail

la configuration du SMTP dans le php.ini n'est valable que pour les serveurs sur du Windows.

Normalement, le SMTP à fournir est celui de ton FAI car tu as un compte chez eux définit par ta boxe. Sinon il existe différents SMTP publics dont j'oublie le nom. Regarde du côté de ton hébergeur, si ça se trouve, le problème provient du port SMTP par défaut de bloqué.

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages