Welcome Guest, Not a member yet? Register   Sign In
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method. (sometimes)
#1

[eluser]Unknown[/eluser]
I'm using the codeigniter email helper to take input from a form and email the contents to my client.

When I use the form (on the live server) it works fine, however when my client uses the same form (again on the live server) he gets this error:

Quote:Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

From: "cody" <>
Return-Path: <>
Reply-To: "" <>
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4c4f60ac3f4cf>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?New_PAV_Question?=
test|| PHONE:

Why would the same server have success and an error message for two different people?

Any ideas?
#2

[eluser]treeface[/eluser]
Could you post the offending code? Are you basing anything on the userdata?
#3

[eluser]Unknown[/eluser]
Code:
&lt;form action="&lt;?php echo $root_url; ?&gt;question/" method="post"&gt;
    <table>
      <tr>
        <td>Name:</td>
    </tr>  
      <tr>
        <td>&lt;input type="text" name="name" /&gt;&lt;/td>
    </tr>
    <tr>
        <td>Email:</td>
    </tr>  
    <tr>
        <td>&lt;input type="text" name="email" /&gt;&lt;/td>
    </tr>
    <tr>
        <td>Phone:</td>
    </tr>  
    <tr>
        <td>&lt;input type="text" name="phone" /&gt;&lt;/td>
    </tr>
    <tr>
        <td>Question?</td>
    </tr>  
    <tr>
        <td>&lt;textarea name="question"&gt;&lt;/textarea></td>
    </tr>
    <tr>
        <td>&lt;input type="submit" value="Send" /&gt;&lt;/td>
    </tr>  
  </table>
  
&lt;/form&gt;

Code:
function question() {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $question = $_POST['question'];
        
        $this->email->from($email, $name);
        $this->email->to("email address");
        $this->email->subject("xxxxxx");
        $this->email->message($question . "|| PHONE: " . $phone);
        $this->email->send();
        
        echo $this->email->print_debugger();
    }
#4

[eluser]treeface[/eluser]
Have you tried sending the mail using PHP's mail function?

http://php.net/manual/en/function.mail.php

If it doesn't work with that, it's your server, not CI.
#5

[eluser]zlatiborac[/eluser]
It is definitely your server, because I had same problems with my webhost. They simple didn't allow PHP mail() function to run.
#6

[eluser]bretticus[/eluser]
So two different persons, using a form at the same URL get two distinct results?

That's what I think you are saying anyway.

Just for fun, drop in a:

Code:
print_r($_POST);

on the form handler and ask your client to send you that output. I've seen Luddites (to be nice) use their IE6 browser on their Windows 95 PC to send forms and seen many crazy things in POST and GET data in logs as a result. This may be that the POST data just isn't coming through for some really strange reason.

I like to add the following email.php file to my application (on the development end but you can try this on the live end too.)

Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| EMAIL CONFING
| -------------------------------------------------------------------
| Configuration of outgoing mail server.
| */
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']=465;
$config['smtp_timeout']=30;
$config['smtp_user']='[email protected]';
$config['smtp_pass']='mypass';
$config['charset']='utf-8';  
$config['newline']="\r\n";

/* End of file email.php */
/* Location: ./system/application/config/email.php */


Because this has to be sent via SSL, this requires the server have PHP openssl support. (Just look for openssl when you run phpinfo() )

The idea is that you are skipping the server's smtp sub system and sending directly to the smtp host designated. Takes the server out of the equation.

Good luck!
#7

[eluser]Unknown[/eluser]
Whoa @Bretticus - thank you. Was having the same problem as noted by the poster with my site hosted on HostGator. I use Google apps to host my mail. The email.php file you provided solved it immediately. Thanks again.
#8

[eluser]cideveloper[/eluser]
I always use google mail with CI. Its awesome and works all the time.




Theme © iAndrew 2016 - Forum software by © MyBB