1

Im trying to create a "contact us" form where visitors will be able to email the site owner.

so far, my form works if the visitor who filled up the form uses a gmail address. but once they use a yahoo email address the recipient(site owner) does not receive the mail

below is how i did the form

controller

public function send_email(){
        $data = $_POST;
        $new = $this->base_model->send_email($data);
        $this->session->set_flashdata("email_status","Message successfully sent");
        redirect(base_url("contact"));
    }

model

public function send_email($email_data)
    {
        $from = $email_data['email'];
        $subject = $email_data['subject'];

        $message = $this->load->view("emails/message",$email_data,TRUE);
        $config['crlf']    = "\n"; 

        $config['mailtype'] = "html";
        $config['protocol'] = "sendmail";

        $this->load->library('email');
        $this->email->initialize($config); 

        $this->email->from($from,$email_data['name']);
        $this->email->to("site owner email address goes here"); 

        $this->email->subject($subject);
        $this->email->message($message);    

        $this->email->send();

        return $this->email->print_debugger();

    }

view

            <?php
                $attributes = array("id"=>"form_req");
                echo form_open("send_email",$attributes);
                ?>

                <div class="controls">
                    <label>Name</label>
                    <input type="text" name="name" class="span12 req">
                </div>

                <div class="controls">
                    <label>Email</label>
                    <input type="text" name="email" class="span12 req">
                </div>

                <div class="controls">
                    <label>Subject</label>
                    <input type="text" name="subject" class="span12 req">
                </div>

                <div class="controls">
                    <label>Message</label>
                    <textarea name="message" class="span12 req"></textarea>
                </div>

                <button class="btn"><i class="fa fa-send"></i> Send</button>
                <?php
                echo form_close();
                ?>

have i missed something? or is there a workaround for this?

itsover9000
  • 561
  • 2
  • 12
  • 32

1 Answers1

1

Is there any reason that the email needs to come "from" the email address that filled in the form? I've had issues in the past with spam filters, Yahoo being one of them, spamming emails where the domain of the website sending the email doesn't match the email address the email is "from". And with good reason, I suppose. Yahoo may be discarding this dangerous looking "spam" before it even reaches the ordinary spam box.

I would try having the emails always come from noreply@your-domain-here.com and add a reply to header if you absolutely want the owner to be able to reply directly to the email.

EDIT: Found this old question with a similar issue, which suggests that changing the from email should solve it: Everytime my mail goes to spam in phpmailer

Community
  • 1
  • 1
HeatherEMSL
  • 285
  • 2
  • 8