0

I'm sure this is going to be a simple solution but when I use my codeigniter email form (i'm on local using xampp) it only sends emails when I enter my own email address in the form - which obviously I want people to enter their own. The whole thing stops working if I delete my email from the sendemail.ini auth_username section so I'm confident it's something to do with that. If I enter my own email in the form then it gets delivered fine. Any ideas what the issue is here?

My Controller

<?php
class Contact extends MX_Controller 
{

function index() {

    if (!isset($data['page_title'])) {
        $data['page_title'] = 'Nail Care & Design in Stoke-on-Trent, Staffordshire';
    }

    if (!isset($data['keywords'])) {
        $data['keywords'] = 'Nails, Weddings, Parties, Beauty, Nailcare';
    }

    if (!isset($data['description'])) {
        $data['description'] = 'Nail Care & Design in Stoke-on-Trent, Staffordshire';
    }

    $data['query'] = $this->get_where(1);
    $data['querytwo'] = $this->get('page_headline');
    $data['message'] = "";

    $this->load->view('pages/header.php', $data);
    $this->load->view('contact/contact_view', $data);
    $this->load->view('pages/footer.php', $data);
}

function send_email() {

    if (!isset($data['page_title'])) {
        $data['page_title'] = 'Nail Care & Design in Stoke-on-Trent, Staffordshire';
    }

    if (!isset($data['keywords'])) {
        $data['keywords'] = 'Nails, Weddings, Parties, Beauty, Nailcare';
    }

    if (!isset($data['description'])) {
        $data['description'] = 'Nail Care & Design in Stoke-on-Trent, Staffordshire';
    }

    $data['query'] = $this->get_where(1);
    $data['querytwo'] = $this->get('page_headline');

    $this->form_validation->set_rules("name", "Name", "required|alpha_numeric_spaces");
    $this->form_validation->set_rules("email", "Email", "required|valid_email");
    $this->form_validation->set_rules("message", "Message", "required");

    if ($this->form_validation->run() == FALSE){

        $data["message"] = "";

        $this->load->view('pages/header.php', $data);
        $this->load->view('contact/contact_view', $data);
        $this->load->view('pages/footer.php', $data);
    } else {
        $data["message"] = "Your email has been successfully sent, thank you.";



       $this->load->library("email");

        $this->email->from(set_value("email"), set_value("name"));
        $this->email->to("myemail@hotmail.co.uk");
        $this->email->subject("Website Enquiry for Love Your Nails");
        $this->email->message(set_value("message"));

        $this->email->send();

        echo $this->email->print_debugger();
aknosis
  • 3,602
  • 20
  • 33
DMinch
  • 27
  • 1
  • 1
  • 8
  • 1
    You're not going to be able to send out mail from a localhost without a special setup or using something like Mailgun. – Adam Oct 17 '17 at 20:49

1 Answers1

0

Delivering emails from your local machine is a gamble. Your emails will get delivered, but because you are not registered as a mail server (roughly speaking - there are many rules that take part here), your emails are most likely to end up in spam or not get accepted at all.

There is something called a "score" when sending an email. It's a combination of all the factors that guarantee you're not a spammer. Every email service has a minimal "score" and below that, it refuses to accept the email.

In your case it looks like hotmail.co.uk accept emails with a lower score and when others enter their email, they reject the mail from your computer.

In other words: You need an email server to send trusted mail. Either:

  • Run your own
  • Rent one
  • Use an smtp server
DreamWave
  • 1,934
  • 3
  • 28
  • 59
  • Ok cool, I'm not actually trying to send real world emails from my local, just in development, but from the sounds of it maybe I should wait til I'm ready to go live and just make sure it works fine once up on my hosting? – DMinch Oct 17 '17 at 21:16
  • @DMinch sounds good. If it works with one email, if the server is configured properly, it will work with all others. – DreamWave Oct 17 '17 at 21:17