请帮我打印这个数组到我的电子邮件 - zend_mail
我是如此接近。我正在尝试将表单的内容打印到电子邮件中。这就是我所拥有的。我可以将内容作为数组显示到我的视图中,但不能将值发送到电子邮件。
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('[email protected]', 'user');
$mail->AddTo('[email protected]', 'joel');
$mail->setSubject('from form');
$mail->setBodyText($emailData);
$mail->send();
} else {
// bad stuff happens
}
}
$this->view->form = $form;
}
}
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('[email protected]', 'user');
$mail->AddTo('[email protected]', 'joel');
$mail->setSubject('from form');
$mail->setBodyText($emailData);
$mail->send();
} else {
// bad stuff happens
}
}
$this->view->form = $form;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
emailData 需要是一个字符串。
这不是最优雅的事情,但它会起作用。
emailData needs to be a string.
Not the most elegant thing but it will work.