Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Form + email question


Go to End


2 Posts   977 Views

Avatar
Beshad

Community Member, 3 Posts

15 August 2016 at 10:52am

Hi guys,
I am new to SilverStripe and just finished/uploaded a SilverStripe site to a server. i have two issues, first is about the contact form and targeting each input field for customisation. i have used a custom form template and i needed to access each input field. i tried $Fields.dataFieldByName(name) and $Fields.FieldByName(email) but they don't work. i ended up using <% control Fields %> $Field <%end_control> which does not give me individual unique styling option for each of my form $Fields. this is what i like to do:
<div class="input-field col s12">
<i class="material-icons prefix">account_circle</i>
$Fields.dataFieldByName(name)
<label for="name">Name</label>
</div>

the other question is about me getting an email after form submission. i have used this:
$email = new Email();
$email->To = "me@myemail.co.nz";
$email->From = $data['email'];
$email->Subject = "A message from : ".$data['name'];;
$email->Body = $data['message'];
$email->send();
this works fine on my localhost but now that i have uploaded the project on my Digital Ocean server it does not send me emails upon form submission. am i missing something here?
thank you for your help
Beshad

Avatar
swaiba

Forum Moderator, 1899 Posts

15 August 2016 at 10:53pm

Very possible that you don't have sendmail - as hackers would love that to send emails from your server so many hosts disable it. I'd contact the host first.

However I'd recommend using https://github.com/markguinn/silverstripe-email-helpers to convert to SMTP or use something like mailgun with this module https://github.com/kinglozzer/silverstripe-mailgunner