Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mails are not sending via form

Discussion in 'E-mail Discussions' started by Mihut Andrei, Nov 18, 2017.

  1. Mihut Andrei

    Mihut Andrei Registered

    Joined:
    Nov 18, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Romania
    cPanel Access Level:
    Website Owner
    Hi everyone,

    I have a problem sending mails via PHPCake. But first of all let's see the context.
    I am not familiar with CakePHP, neither working with Cpanel. My uncle has a website where people could make a reservation. After a form is completed a mail with the details is sent to the company. Like for 6 months he didn't receive any mails. I entered his website and completed a form, click on a button to make a reservation, but no mail was sent. I took a look on the code, but everything seems to be fine there.

    PHP:
    <?php
    class ContactsController extends AppController {

    var 
    $name 'Contacts';
    var 
    $components = array('Captcha''Email');

    function 
    beforeFilter(){
        
    parent::beforeFilter();
        
    $this->Captcha->model 'Contact';
    }

    function 
    index(){
        if(!empty(
    $this->data)){
            if(
    $this->Captcha->validate()){
                
    $this->Contact->set($this->data);
                if(
    $this->Contact->validates()){
                    
    $this->set('email_data'$this->data);
                    
    $this->Email->reset();
                    
    $this->Email->to 'somebody@gmail.com';         
                    
    $this->Email->subject __('Contact prin form web',true).' : '.$this->data['Contact']['subject'];     
                    
    $this->Email->replyTo $this->data['Contact']['email'];     
                    
    $this->Email->from $this->data['Contact']['name'];
                    
    $this->Email->layout 'contact'// note no '.ctp'     
                    
    $this->Email->template 'contact_email'// note no '.ctp'
                    //Send as 'html', 'text' or 'both' (default is 'text')
                    
    $this->set('contact',$this->data);
                    
    $this->Email->sendAs 'html'// because we like to send pretty mail
                    
    $this->Email->send();
                    
    $this->Session->setFlash(__('Mesajul a fost trimis. Va vom raspunde cat mai repede posibil.'true));
                    
    $this->redirect(array('action'=>'index'));                       
                }               
            }else{

                
    $this->Session->setFlash(__('Nu ati raspuns corect la intrebarea matematica.' $this->data['Contact']['name'], true));
                
    $this->redirect(array('action'=>'index'));
            }
        }
        
    $this->set('title''Some title');
        
    $this->set('captcha',$this->Captcha->generate());
        }       
    }
    ?>
    It worked before, it is not working like for 6 months. Is there a file where the mail settings are configured in Cpanel? Can I check for some logs somewhere? It is possible that the rights to send mails to expire or something like that?

    Thank you for helping!

    PS: The code is not written by me :).
     
  2. SysSachin

    SysSachin Well-Known Member

    Joined:
    Aug 23, 2015
    Messages:
    604
    Likes Received:
    41
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Can you please check the logs , tail -f /var/log/exim_mainlog and then send a email and let us know.

    Also check if you have not disable php email on the server.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    41,484
    Likes Received:
    1,612
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Your access level shows as "Website Owner". I recommend reporting this issue to your web hosting provider so they can verify if sending email via PHP is allowed (or disabled) on the server.

    Thank you.
     
Loading...

Share This Page