Please help me print this array to my email- zend_mail
I'm so dang close. I'm trying to print the contents of a form to an email. Here's what I have. I'm able to pront the contents as an array to my view, but not send the values to the email.
public function indexAction()
{
$formData = array();
$emailData = array();
$form = new Application_Form_Contact();
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
foreach ($formData as $d){
$emailData[] = $d;
}
$mail = new Zend_Mail();
$mail->setFrom('me@me.com', 'user');
$mail->AddT开发者_Python百科o('me@me.com', 'joel');
$mail->setSubject('from form');
$mail->setBodyText($emailData);
$mail->send();
} else {
// bad stuff happens
}
}
$this->view->form = $form;
}
}
emailData needs to be a string.
$emailData = "Email content: ";
foreach ($formData as $d){
$emailData .= $d . "\r\n";
}
Not the most elegant thing but it will work.
精彩评论