ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

PHP mail() email protocol not working

September 29, 2008 9:46am

Subscribe [3]
  • #1 / Sep 29, 2008 9:46am

    elemental

    77 posts

    - build 20080829
    - Server is Apache with PHP Version 5.2.6

    When I try to send an email from the communicate section i get an error “Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.”

    But using just plain php to test the mail() function mail gets send no problem. I sense that this a compatibility issue between EE and the hosting setup but it seems awkward, knowing that the plain php scripts execute well.

    Any pointers/directions are appreciated
    thank in advance

  • #2 / Sep 29, 2008 10:19am

    Robin Sowell

    13255 posts

    Hm- did you run through this kblog entry on email tweaks.  And if debugging is turned on, the only message is ‘Unable to send’ - or does debug give us a bit more detail.

    Also- who’s the host, just in case there are known issues.

  • #3 / Sep 29, 2008 11:21am

    elemental

    77 posts

    Thanks Robin for the reply,

    - Checked the kblog entry and all is by standards.
    - Had debugging turned on already. As I mentioned the debugger give this error detail:

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

    - The hosting company is a small slovak company but for the records it’s exohosting.sk

    PS at the time I cannot use the SMTP gateway but I am trying to get access rights from the provider to try that method as a replacement for the mail() function method. Still it’s strange that it does not work

  • #4 / Sep 29, 2008 11:34am

    Robin Sowell

    13255 posts

    Hm- ok, any difference with sendmail?  And when you tested pure php, can you paste the core of that code.  I’ll poke around, see if I can spot the difference.

  • #5 / Sep 29, 2008 11:53am

    elemental

    77 posts

    Sendmail gives:

    Debugging Message
    Unable to open a socket to Sendmail. Please check settings.
    Unable to send email using Sendmail

    The plain PHP mail() test code is:

    <?php
    $to = "[email protected]";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "[email protected]";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    ?>

     

    When I asked the hosting company they told me to use PHP mail()

  • #6 / Sep 29, 2008 12:01pm

    Robin Sowell

    13255 posts

    Hm- just poking code here.  Can you turn php on in a template, paste the following and let me know what you get.

    <?php
    
    $safe_mode = (ini_get("safe_mode") == 0) ? 'f' : 't';
    echo $safe_mode;
    
    ?>
  • #7 / Sep 29, 2008 12:11pm

    elemental

    77 posts

    the page renders “f”

  • #8 / Sep 29, 2008 12:18pm

    Robin Sowell

    13255 posts

    Hm.  OK- want to just test something and see if it matters?  In system/core/core.email.php around line 1190 you’ll spot where EE actually sends via mail:

    /**  Send using mail()
        /** -------------------------------------*/
    
        function send_with_mail()
        {    
            if ($this->safe_mode == TRUE)
            {
                if ( ! mail($this->recipients, $this->subject, $this->finalbody, $this->header_str))
                    return false;
                else
                    return true;        
            }
            else
            {
                if ( ! mail($this->recipients, $this->subject, $this->finalbody, $this->header_str, "-f".$this->clean_email($this->headers['From'])))
                    return false;
                else
                    return true;
            }
        }
        /* END */

    Let’s just flip that safemode conditional and try it once.  See what happens.  So

    ($this->safe_mode == TRUE)
    change to
    ($this->safe_mode != TRUE)

    We’ll force it to use the first option, which is similar to the pure php test.

  • #9 / Sep 29, 2008 12:28pm

    elemental

    77 posts

    Success!

    Does that mean that turning PHP safe_mode off will sort it out SO i don’t have to hack the core.email.php?
    Thank you Robin

  • #10 / Sep 29, 2008 12:30pm

    elemental

    77 posts

    Just checked PHP info and the safe_mode was off. maybe it;s a different safe_mode for the mail section.

  • #11 / Sep 29, 2008 12:42pm

    Robin Sowell

    13255 posts

    Yea- I think it’s a different safe mode.  And let’s not count this as solved.  Cause- well, we had to hack.  I want to ask the crew about it.  So- hang around a bit.

  • #12 / Sep 29, 2008 12:51pm

    Robin Sowell

    13255 posts

    OK- do me this.  Let us know your sendmail_path settings in your PHP ini.

  • #13 / Sep 29, 2008 1:59pm

    elemental

    77 posts

    Seems like the host is down for the moment. I am going home. Will post as soon as I can

  • #14 / Sep 29, 2008 2:12pm

    Greg Aker

    6022 posts

    elemental:

    Thanks for the update, please let us know when you get it. 

    -greg

  • #15 / Sep 30, 2008 3:07am

    elemental

    77 posts

    The local value of the sendmail_path is: /usr/sbin/sendmail -t -i -f .(JavaScript must be enabled to view this email address)

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases