EvilZone

Programming and Scripting => Web Oriented Coding => : lucid April 24, 2013, 01:06:16 AM

: [PHP] Email form
: lucid April 24, 2013, 01:06:16 AM
Hey guys. I'm writing an email form to be part of a larger project I'm working on(I'll be releasing here soon enough ;D ) and I can't seem to get the email form to work. I'm sure it's all correct and I'm also sure there is some tiny bit that I'm doing wrong. Everything works except I never receive an email.

Code:
: (php)
<?php

if(isset($_POST['message']) && !empty($_POST['message']))
{
    if(
mail('lucid@evilzone.org','Feedback'htmlspecialchars($_POST['message'])))
    {
        
$status "Your message has been delivered to lucid@evilzone.org";
    } 
    else 
    {
        echo 
"Failed to deliver message";
    }
}            
    
?>


<table width='100%' height='1' cellspacing='5' cellpadding='5' bordercolor='#0ABFFF' border='1' bgcolor='#333333' bordercolorlight='#c0c0c0' bordercolordark='#666666' style='border-collapse: collapse;'>
    <tr>
        <td>
            <b>Submit Feedback and Reports Here</b><br><br><form action='?a=fdbk'           method='post'><b>Email: </b><input type='text' name='email'><br><br><b>Name: </b><input type='text' name='email'><br><br><b>Message: </b><br><textarea rows='10' cols='60' name='message'></textarea><br><input type='submit' value='Send'></form>
        </td>
        <?php if(isset($status)) echo $status?>
    </tr>
</table>

That's the relevant part of the code.
: Re: [PHP] Email form
: relax April 24, 2013, 01:39:59 AM
if you run the server locally check the settings if you run from host check they support it.
: Re: [PHP] Email form
: lucid April 24, 2013, 02:24:05 AM
Well I just installed sendmail(I didn't realize it wasn't installed) and added this to /etc/php/php.ini:

:
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail

And now the success message doesn't happen. Instead I get my error message... I guess I'm getting somewhere because something changed but obviously getting the error message isnt' good.
: Re: [PHP] Email form
: relax April 24, 2013, 02:37:39 AM
Well I just installed sendmail(I didn't realize it wasn't installed) and added this to /etc/php/php.ini:

:
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail

And now the success message doesn't happen. Instead I get my error message... I guess I'm getting somewhere because something changed but obviously getting the error message isnt' good.


would be helpful to know what the error msg says :P
: Re: [PHP] Email form
: Stackprotector April 24, 2013, 09:49:10 AM
Your mail.err log always tells you good errors please post it. Though it should probably be some hostname resolving issues or something stupidlike that.
: Re: [PHP] Email form
: lucid April 24, 2013, 11:10:20 PM

would be helpful to know what the error msg says
The error message is one I created in the code where the else statement is. It's not an actually php error. Everything seems to be working fine except evidentally POST['message'] is not set since my else statement is the one that echos.

@Faction - For whatever reason, I never had an error log file. I had to create it and point to it in /etc/php/php.ini. And even then...it contains nothing.

:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
; mail.add_x_header = On

; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
 mail.log = /var/log/mail.log
; Log mail to syslog (Event Log on NT, not valid in Windows 95).
 mail.log = syslog

That's the only relevant mail area in /etc/php/php.ini. I didn't find anything of use in http.conf.

I could post my httpd/error_log but I don't think that's it.

:
[Wed Apr 24 15:57:00 2013] [notice] caught SIGWINCH, shutting down gracefully
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 15:57:00 2013] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Wed Apr 24 16:05:27 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed Apr 24 16:05:29 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Apr 24 16:05:29 2013] [warn] module php5_module is already loaded, skipping
[Wed Apr 24 16:05:29 2013] [notice] Digest: generating secret for digest authentication ...
[Wed Apr 24 16:05:29 2013] [notice] Digest: done
[Wed Apr 24 16:05:33 2013] [notice] Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.1e DAV/2 PHP/5.4.13 configured -- resuming normal operations
[Wed Apr 24 16:06:12 2013] [error] [client 127.0.0.1] File does not exist: /home/lucid/code/php/favicon.ico
[Wed Apr 24 16:06:12 2013] [error] [client 127.0.0.1] File does not exist: /home/lucid/code/php/favicon.ico