Author Topic: [PHP] Email form  (Read 1356 times)

0 Members and 1 Guest are viewing this topic.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
[PHP] Email form
« on: 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:
Code: (php) [Select]
<?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.
« Last Edit: April 24, 2013, 01:07:57 am by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline relax

  • Sir
  • ***
  • Posts: 562
  • Cookies: 114
  • The one and only
    • View Profile
Re: [PHP] Email form
« Reply #1 on: 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.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: [PHP] Email form
« Reply #2 on: 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:

Code: [Select]
; 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.
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline relax

  • Sir
  • ***
  • Posts: 562
  • Cookies: 114
  • The one and only
    • View Profile
Re: [PHP] Email form
« Reply #3 on: 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:

Code: [Select]
; 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

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [PHP] Email form
« Reply #4 on: 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.
~Factionwars

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: [PHP] Email form
« Reply #5 on: 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.

Code: [Select]
[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.

Code: [Select]
[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
« Last Edit: April 24, 2013, 11:14:59 pm by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python