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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Showcase Questions /

Feedback and questions about sites in the Community Showcase.

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

Contact Form Module


Go to End


3 Posts   1529 Views

Avatar
cdwilliams

Community Member, 8 Posts

21 July 2015 at 12:40pm

Hello,

i am attempting to have the contact form module dynamically use the submitter's e-mail address in the "From" field when the e-mail is sent from the website. The code block i am including below mentions to define MAIL_FROM_ADDRESS in the mysite/_config.php file, but i am unsure how to do this. Any ideas? Thank you.

//You can define MAIL_FROM_ADDRESS in mysite/_config.php
$sender = null;
if(defined('MAIL_FROM_ADDRESS')) $sender = MAIL_FROM_ADDRESS;
$email = Email::create($sender, $emailTo, $emailSubject, $html);
if($replyTo) {
$email->replyTo($replyTo);
}

Avatar
Pyromanik

Community Member, 419 Posts

21 July 2015 at 10:24pm

Contact form module?
Could you post a link? It's not an 'official' one, and many developers approach these simple tasks in various ways.

It sounds like it's far more complex than it needs to be. Often for a simple contact form a good solution is simply UserForms module.
In any case, using a defined static constant is not what you want to be doing if you're trying to send from the submitter's supplied address.
It's simply a case of setting the from parameter in the email to the submitted form field value.

Beyond that it's eceedingly simple to create a small form to use without needing a whole module. I would suggest perhaps looking at the tutorials (docs.silverstripe.org) to learn more.

Avatar
cdwilliams

Community Member, 8 Posts

22 July 2015 at 6:08am

Pyro,

Thank you. That helped me solve the issue. I did exactly as you said and the form is working fine now ("setting the from parameter in the email to the submitted form field value"). I appreciate the help. Next time, I'll consider using the UserForms Module.

Just so you know, i was using "Silverstripe Contact Form Module", as maintained by Uncle Cheese...http://addons.silverstripe.org/add-ons/silverstripe/contact-form.

Charles