Php mail form not working

software development

#1

I´m having problems with my contact form. It works perfect in every other server i try it, but when i upload it to dreamhost i don´t recieve any e-mail.

this is the php code:

<? //!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']) if(1) { $to = 'pablo@kidart.com.ar'; $subject = "Irene Brandt Webmail"; $body = stripslashes($HTTP_POST_VARS['sender_messag']); $body .= "\n\nThe following person has subscribed to your maillist \n"; $body .= "name: " . $HTTP_POST_VARS['sender_name'] . ", email: " . $HTTP_POST_VARS['sender_mail'] . ", country: " . $HTTP_POST_VARS['sender_subject'] . ", profession: ". $HTTP_POST_VARS['sender_message'] ."\n"; $header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n"; $header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n"; $header .= "X-Mailer: PHP/" . phpversion() . "\n"; $header .= "X-Priority: 1"; if(mail($to, $subject, $body, $header)) { echo "output=sent"; } else { echo "output=error"; } } else { echo "output=error"; } ?>

do i have to edit the php.ini to enable the php mail () function??

I would really apreciate to have a little help with this, it´s the last thing to solve before launching the site.


#2

Didn’t read the code (and am off to bed!) but noticed in the feed that you’re using short tags.

[color=#0000CC]<?php[/color]

echo “Need some sleep!”;

[color=#0000CC]?>[/color]

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

I am having the same problem. Since DH moved me from one server to another, mail() returns false and I am not amused.

Short tags should not make any difference.


The subtle source is clear and bright
The tributary streams flow through the darkness

http://davidmintz.org/


#4

so it´s impossible to make any contact form work???

i´m doing this site in flash, is there any other way to have a mail form???

the url is: http://www.irenebrandt.com/new/irenebrandt_white.html
the form is in the “contact” section…


#5

I don’t know your specific environment or the nature of your error, but in my case, I had a custom php.ini which had no setting for sendmail_path. I set it to

sendmail_path = “/usr/sbin/sendmail -t -i”

that is, same as /etc/php5/cgi/php.ini, and it’s working.

I imagine others will run into this issue following the server switch, so let me repeat that again loudly:

if you have a custom php.ini, you need to have sendmail_path = “/usr/sbin/sendmail -t -i”


The subtle source is clear and bright
The tributary streams flow through the darkness

http://davidmintz.org/


#6

Another thing, I see you are using the $HTTP_POST_VARS array and that is long deprecated – unsupported even – in modern PHP. Use $_POST instead.


The subtle source is clear and bright
The tributary streams flow through the darkness

http://davidmintz.org/


#7

thank you very much.
i´ll try fixing it that way.
can you tell me how to edit php.ini?

i´ve to find the “sendmail” line in that file, and replace it with the one you told me?


#8

ok. i´ve already edit the phpini , and replace the sendmail_path: nothing changed. the form can´t send any email…

any other tip or idea?


#9

How is your code looking now?


#10

my code look like this:

<? //!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']) if(1) { $to = 'mymail@kidart.com.ar'; $subject = "Irene Brandt Webmail"; $body = stripslashes($_POST['sender_messag']); $body .= "\n\nThe following person has subscribed to your maillist \n"; $body .= "name: " . $_POST['sender_name'] . ", email: " . $_POST['sender_mail'] . ", country: " . $_POST['sender_subject'] . ", profession: ". $_POST['sender_message'] ."\n"; $header = "From: " . $_POST['sender_name'] . " <" . $_POST['sender_mail'] . ">\n"; $header .= "Reply-To: " . $_POST['sender_name'] . " <" . $_POST['sender_mail'] . ">\n"; $header .= "X-Mailer: PHP/" . phpversion() . "\n"; $header .= "X-Priority: 1"; if(mail($to, $subject, $body, $header)) { echo "output=sent"; } else { echo "output=error"; } } else { echo "output=error"; } ?>

The curious thing is that i´ve tried every single flash contact form script i found on the internet: everyone works perfect when i use it in my old server but when i upload the same files to dreamhost, without changin anything… it doesnt work.
I don´t know what to do… the only answer seems to be changing my hosting service??


#11

They will if short_open_tag is OFF (which is the default when one sets up PHP).

sendmail is already in the path, no need to edit it unless the php build is trash.

Check out Atropos7’s post from last week in which he included a nice piece of code that tests conditions.

The part down the bottom after [color=#00CC00]($_SERVER[‘REQUEST_METHOD’] === ‘POST’)[/color] shows how to format the send correctly.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#12

Headers must be separated with “\r\n” not “\n” - that’s what the standard says.


#13

If short tags are enabled, the script will be parsed and the style of the tag has no bearing on mail() – that’s my point

As for sendmail_path, my experience suggests that if this directive is not found by PHP, it falls back on a default which does not work on certain DH servers, and mail() returns false.


The subtle source is clear and bright
The tributary streams flow through the darkness

http://davidmintz.org/


#14

If you install PHP following a Wiki script open_short_tags won’t be enabled. Which was my point :wink:

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost