Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » email functionality not working

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1458 Views
  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    email functionality not working Link to this post

    Hi Gurus

    On a couple of sites, I have noticed that the email functionality is broken (no emails are sent). To me, it would be more likely that there is something wrong with the server than with silverstripe as such. Question is - how do I work out where the problem lies? Emails sent seem to disappear into a black hole.

    A special point to consider is that for my current client, it appears the standard contact form is not working. This can be very frustrating for the client - as they set it up and can not understand why it is not working.

    Any thoughts are greatly appreciated.

    Nicolaas

  • Nicolaas
    Avatar
    Forum Moderator
    213 Posts

    Re: email functionality not working Link to this post

    Hi Folk

    I created the following file:
    /mysite/code/emailTestPage.php

    ----------------------------------------------------------------------------
    <?php

    class emailTestPage extends Page {

    }

    class emailTestPage_Controller extends Page_Controller {
    var $mailTo = 'myemail@mysite.com';
    var $subject = 'subject Line';
    var $message = 'message goes here';
    var $adminEmail = "myadmin@mysite.com";

    function testButtons() {
    return '
    <ul>
    <li><a href="/emailTest/mailExec">test mail functions</a></li>
    </ul>';
    }

    function getAdminAdress () {
    Email::setAdminEmail($this->adminEmail);
    return "<br />admin email address is: ".Email::getAdminEmail();
    }

    function mailExec() {
    if( mail($this->mailTo, $this->subject, $this->message) ) {
    $v .= '<br />message sent to '.$this->mailTo.' using php mail function';
    }
    else {
    $v .= '<br />could not send message to '.$this->mailTo.' using php mail function';
    }
    $e = new Email($this->adminEmail, $this->mailTo, $this->subject, $message);
    $outcome = $e->send();
    $v .= 'the outcome of sending an email using silverstripe was as follows: '.$outcome;
    return $v;
    }

    }
    ----------------------------------------------------------------------------

    and the following template:
    /mysite/templates/layout/

    ----------------------------------------------------------------------------
    $testButtons
    $getAdminAdress
    ----------------------------------------------------------------------------

    It showed me that there was nothing wrong with the email function so it must be in the templating in /cms/code/PageTypes/UserDefinedForm.php - not sure what it is....

    Any help appreciated.

    Nicolaas

    1458 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.