21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1431 Views |
-
My form cant send email

11 May 2009 at 8:50pm Last edited: 11 May 2009 10:38pm
i have the following function in my page.php. its appears on every page as a quick contact form.
the problem is that it can populate the database but its not sending me the data thru email.function submitContact($data, $form) {
$submission = new ContactFormSubmission();
$form->saveInto($submission);
$email = new Email($data->Email, "name@yourdomain.com", "Quick contact from website", $data->Message);
$email->send();
$submission->write();
Session::set('Contacted', true);
Director::redirectBack();
} -
Re: My form cant send email

12 May 2009 at 7:28pm
Have you already checked to send a simple e-mail? Example: $email = new Email ( return adress, your adress, subject, body).
I think that SilverStripe can't create the $body. Furthermore you can check this with Debug::Dump(). -
Re: My form cant send email

13 May 2009 at 9:53pm
thanks PGiessler
if my statement is like this as you said it, it works
$email = new Email ( from@yourdomain.com , to@yourdomain.com, subject, body).
but the moment i try to populate the $data it wont send emails to me.
now ca you help me get this $data populated.thank you
-
Re: My form cant send email

14 May 2009 at 7:28pm
Hello patty,
I corrected your source code, now you're able to send the email. You declare $data as an Object but it's an array.
This was the only mistake! If my solution doesn't work, please write it down so I can look over the source code again.Best regards
Pascal
//modified SubmitContact
function submitContact($data, $form) {
$submission = new ContactFormSubmission();
$form->saveInto($submission);
$submission->write();$email = new Email($data['Email'], "name@yourdomain.com", "Quick contact from website", $data['Message']);
$email->send();Session::set('Contacted', true);
Director::redirectBack();
}
| 1431 Views | ||
|
Page:
1
|
Go to Top |


