Zend Mail problem.

For programming and general questions on Zend Framework
Post Reply
lukaszl446
Posts: 2
Joined: Fri Nov 02, 2012 5:19 pm

Zend Mail problem.

Post by lukaszl446 » Fri Nov 02, 2012 5:30 pm

Hey,
I created new default project in ZF.

in index method I put:

Code: Select all

$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('somebody[at]example[dot]com', 'Some Sender');
$mail->addTo('somebody_else[at]example[dot]com', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send();
[at] and [dot] ofc means "@ "and "." (i cant put here links and emails)

and when I open a page I get error 500 Internal Server Error... but I have this email in my mailbox.

I tested this on ZF 1.10 and 1.12. ZF CE

Regards,
lukaszl446

kustome
Posts: 4
Joined: Tue Nov 06, 2012 4:19 pm

Re: Zend Mail problem.

Post by kustome » Tue Nov 06, 2012 4:21 pm

Have you tried to add in a redirect?

$this->_redirect('/home');

or if you are looking to just stay on that current page after sending the email.. try $this->_redirect($this->view->url());

facingwest
Posts: 18
Joined: Fri Sep 23, 2011 4:46 pm

Re: Zend Mail problem.

Post by facingwest » Wed Nov 07, 2012 2:58 pm

kustome wrote:Have you tried to add in a redirect?

$this->_redirect('/home');

or if you are looking to just stay on that current page after sending the email.. try $this->_redirect($this->view->url());

Wouldn't redirecting to itself just generate an infinite loop?

The process executes the $mail->send() otherwise you wouldn't have gotten the email, so i'm inclined to believe that the problem is elsewhere. Does this page have anything else in it? If you remove the Zend_Mail call completely does the error go away? Which method are you calling this from and as mentioned above what happens when you redirect to a different method within the same controller after sending the email?

lukaszl446
Posts: 2
Joined: Fri Nov 02, 2012 5:19 pm

Re: Zend Mail problem.

Post by lukaszl446 » Sat Dec 22, 2012 2:49 am

Does this page have anything else in it?
No, just default zf project.
If you remove the Zend_Mail call completely does the error go away?
Yes.
Which method are you calling this from and as mentioned above what happens when you redirect to a different method within the same controller after sending the email?
I put this send email code in "indexAction" method. I can't redirect to different method after sending email. Script stops after line $mail->send(); and I get 500 Internal Server Error (display_errors does not work in this case).

cone27
Posts: 1
Joined: Fri Jan 13, 2012 12:58 pm

Re: Zend Mail problem.

Post by cone27 » Wed Jun 18, 2014 12:30 pm

I got the same!
any idea why??

Thanks, Rafal

inte3579
Posts: 1
Joined: Wed Jun 25, 2014 12:27 pm
Contact:

intelliteams

Post by inte3579 » Wed Jun 25, 2014 12:31 pm

HI,
I also facing the same problem :(

Any suggestion plz????

intelliteams. com

Post Reply