Estoy intentando enviar un e-mail con ZendMail (este script sencillo resume todo)¿Problema al enviar correo con Zend Mail?
<?php
require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
$mail->setBodyText('My Nice Test Text');
$mail->setBodyHtml('My Nice Test Text');
$mail->setFrom('[email protected]', 'Mr Example');
$mail->addTo('[email protected]', 'Mr Test');
$mail->setSubject('TestSubject');
$mail->send();
?>
Sin embargo consigo este seguimiento de la pila:
Fatal error: Uncaught exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. ' in /usr/share/php/libzend-framework-php/Zend/Mail/Transport/Sendmail.php:137 Stack trace: #0 /usr/share/php/libzend-framework-php/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Sendmail->_sendMail() #1 /usr/share/php/libzend-framework-php/Zend/Mail.php(1178): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail)) #2 /var/www/hexreaction/mail/index2.php(11): Zend_Mail->send() #3 {main} thrown in /usr/share/php/libzend-framework-php/Zend/Mail/Transport/Sendmail.php on line 137
EDIT:
I No estoy tratando de usar SMTP para enviar mi correo electrónico y estoy teniendo un problema menos horrible, pero sigue siendo un problema.
<?php
require_once 'Zend/Mail.php';
$config = array('auth' => 'login',
'username' => '[email protected]',
'password' => 'secretpass');
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);
?>
de este tiro este error, yo realmente no entiendo por qué:
Fatal error: Class 'Zend_Mail_Transport_Smtp' not found in /var/www/hexreaction/mail/index3.php on line 7
EDIT 2:
Este es mi código de trabajo final
require_once('Zend/Mail/Transport/Smtp.php');
require_once 'Zend/Mail.php';
$config = array('auth' => 'login',
'username' => '[email protected]',
'password' => 'somepass',
'ssl' => 'tls');
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);
Actualizado Goles respuesta necesita añadir ** 'SSL' => 'TLS', ** en la parte superior para evitar errores ver mi respuesta –
esto es increíble; gracias por la actualización; Voy a hacer eso para mis preguntas en el futuro también. – Ahdee