Manu,

you could try to use PHP function "ini_get" to get the value from your
php.ini file. It takes the name of the setting as parameter, e.g.:
ini_get("smtp_port");

Although I beleive that the Zend_Mail_Transport_Smtp class should do
this itself.

You could also use "templating" to prevent passing around the same
parameters to the class all the time. Just create a subclass (e.g.
My_Mail_Transport_Valueone) of Zend_Mail_Transport_Smtp with a
constructor without parameters. In this constructor you set
$this->_host, $this->_port and $this->_myName to the values you want.

I hope this helps.

With regards,

Allard Buijze

On 10/20/06, Manu Goel <[EMAIL PROTECTED]> wrote:
Hi André,

I am so sorry for providing incomplete details. And thanx for your feedback.

I think we dont have to use connect() till the time we are not sending
multiple mails using the same transport. And in my case I am going to use
multiple transports.

Actually, it was taking port 25 as the default, even after setting the
"smtp_port " in php.ini. This was the Warning shown


Warning: stream_socket_client() [function.stream-socket-client ]: unable to
connect to tcp://mail.value-one.com:25 (A connection attempt failed because
the connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond.
) in c:\wamp\www\library\Zend\Mail\Transport\Smtp.php on
line 97


So, as a result i was not getting any mails. I looked at the class
definition for a while and then found the following simple solution.

instead of using this:
$tr = new Zend_Mail_Transport_Smtp( ' mail.value-one.com' );

use this:
$tr = new Zend_Mail_Transport_Smtp( ' mail.value-one.com', '521' );


This works just fine, although I have not tried it with attachments as yet.
Now, my question is, is this the only way?? How can I make this a global
setting so that I dont have to mention it everytime.


regards,

Manu Goel




On 10/18/06, André Hoffmann <[EMAIL PROTECTED] > wrote:
> Don't you have to _connect() when using SMTP?
>
> It might also be useful to hear what is not working, from your mail I'm
guessing you don't receive the mail you send. Is there any Exception thrown?
>
>
>
> On 10/18/06, Manu Goel <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I needed to use the Zend Mail API from the Zend Framework. I have done
the following configuration but it is not working
> >
> >
> > 1) PHP.INI
> >     SMTP = " mail.e11online.com "
> >     smtp_port = 521
> >     sendmail_from = [EMAIL PROTECTED]
> >
> > 2) I have written the following code in the controller
> >
> >                 Zend::loadClass('View_dbhandler');
> >                 $dbhandler = new View_dbhandler();
> >
> >                 $to = $_POST['to'];
> >                 $cc = $_POST['cc'];
> >                 $bcc = $_POST['bcc'];
> >                 $from = " [EMAIL PROTECTED]";
> >                 $subject = $_POST['subject'];
> >                 $bodyText = $_POST['bodyText'];
> >
> >                 $dbhandler->compose($to, $cc, $bcc, $from, $subject,
$bodyText);
> >
> > 3) This the PHP file in which I have defined the dbhandler class and the
compose method
> >
> >
> > require_once('Zend/Mail.php');
> >
> > require_once('Zend/Mail/Transport/Smtp.php');
> > $tr = new Zend_Mail_Transport_Smtp(' mail.value-one.com');
> > Zend_Mail::setDefaultTransport($tr);
> >
> > class View_dbhandler
> > {
> >     function compose($to, $cc, $bcc, $from, $subject, $bodyText)
> >     {
> >         $mail = new Zend_Mail();
> >
> >         $mail->setBodyText($bodyText);
> >         $mail->setBodyHtml($bodyText);
> >         $mail->setFrom($from);
> >         $mail->addTo($to);
> >         $mail->setSubject($subject);
> >
> >         $mail->send();
> >     }
> > }
> >
> >
> > Please let me know if I am doing anything wrong. A quick reply would be
highly appreciated.
> >
> >
> > Regards,
> >
> > Manu Goel
> > Value One
> >
> >
>
>
>
> --
> best regards,
> André Hoffmann
> ZF-Blog: http://andrehoffmann.wordpress.com/



--

Manu Goel
-----------------------------------
Visit me at
[www.orkut.com/Profile.aspx?uid=6505992462906698128 ]
[www.manugoel.blogspot.com]
[www.manugoel.hi5.com]

Reply via email to