FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Trouble with sending e-mail from simple php script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Trouble with sending e-mail from simple php script [message #176481 is a reply to message #176473] Sun, 08 January 2012 14:09 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 1/8/2012 4:20 AM, C wrote:
> On Jan 7, 11:06 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 1/7/2012 2:01 PM, C wrote:
>>
>>
>>
>>
>>
>>> I have a simple form which is handled in a *.htm file by
>>
>>> <FORM METHOD="POST" ACTION="send_msg.php">
>>> <PRE>
>>> Your name<INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
>>> Company<INPUT TYPE="text" NAME="orgn" MAXLENGTH=60 SIZE=50>
>>> City and country<INPUT TYPE="text" NAME="locn"
>>> MAXLENGTH=60 SIZE=50>
>>> Your e-mail address<INPUT TYPE="text" NAME="emad" MAXLENGTH=60
>>> SIZE=50>
>>> Your message<TEXTAREA NAME="question" WRAP=VIRTUAL
>>> ROWS=5 COLS=45></TEXTAREA>
>>> <INPUT TYPE="submit" VALUE="Send message">
>>> </PRE>
>>> </FORM>
>>
>>> Then the send_msg.php should send the e-mail by the following code
>>> (but does not send e-mail). What am I doing wrong?
>>
>>> <?php
>>> $date = date("F jS Y, h:iA");
>>> if ($name == ""&& $question == "") {exit;}
>>> $host=@gethostbyaddr($REMOTE_ADDR);
>>> $headers = "From: postmas...@domainname1.org \r\n";
>>> $headers .= "X-Mailer: PHP \r\n";
>>> if(mail("myusernameh...@gmail.com", "Comments from someone.",
>>> "$host on the contacts page at $date \n
>>> --- \n
>>> $name from $orgn, $locn ($emad) wrote:\n\n
>>> $question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
>>> not sent"; }
>>> echo $msg;
>>> ?>
>>
>>> <html>
>>> <head>
>>> <title>Test form to email</title>
>>> </head>
>>
>>> <body>
>>> <?php echo $msg ?>
>>
>>> </body>
>>> </html>
>>
>>> <?php
>>> echo "<HTML>";
>>> echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
>>> topmargin="20">';
>>> echo '<FONT face="Arial" size=1> <B>';
>>> echo $msg ;
>>> echo "Thank you. Your message has been sent.";
>>> echo "</B> </FONT> </HTML>";
>>> ?>
>>
>>> Thanks for all help/replies.
>>
>>> By the way, PHP.INI contained the following but suspecting this to be
>>> a problem, I removed the file, and it still does not work.
>>
>>> register_globals = off
>>> allow_url_fopen = off
>>
>>> expose_php = Off
>>> max_input_time = 60
>>> variables_order = "EGPCS"
>>> extension_dir = ./
>>> upload_tmp_dir = /tmp
>>> precision = 12
>>> SMTP = relay-hosting.secureserver.net
>>> url_rewriter.tags =
>>> "a=href,area=href,frame=src,input=src,form=,fieldset="
>>
>>> ; Only uncomment zend optimizer lines if your application requires
>>> Zend Optimizer support
>>
>>> ;[Zend]
>>> ;zend_optimizer.optimization_level=15
>>> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
>>> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
>>> Optimizer_TS-3.3.3
>>> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
>>> ZendExtensionManager.so
>>> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
>>> ZendExtensionManager_TS.so
>>
>>> ; -- Be very careful to not to disable a function which might be
>>> needed!
>>> ; -- Uncomment the following lines to increase the security of your
>>> PHP site.
>>
>>> ;disable_functions =
>>> "highlight_file,ini_alter,ini_restore,openlog,passthru,
>>> ; phpinfo, exec, system, dl, fsockopen, set_time_limit,
>>> ; popen, proc_open,
>>> proc_nice,shell_exec,show_source,symlink"
>>
>> In addition to what LUUK said - there can be a lot of problems -
>> anywhere from your SMTP server rejecting the message for any of a number
>> of reasons to the client machine rejecting the message.
>
> Even if the message were rejected, I would still see something in that
> frame, but I get only a blank frame. Client machine rejecting the
> message should not even be noticed by this PHP script, or would it?
>

No, but then neither will the SMTP server rejecting the message.

You have other problems also, like trying to echo $msg before the
<html>, etc. are sent. But that isn't causing the message to not be
received.

Of course, getting a blank frame is a completely different problem than
you first reported, and usually means a fatal error in your PHP script.
That needs to be found and fixed first.

>>
>> P.S. unless you are E. Mousa from time Advertising Agency, you should
>> not be using his domain name in your code.
>
> Which domain name does he have? I can of course use example.***.
>

The domain you used in your example.

> You should instead use
>> example.com, example.org, etc., which are specifically reserved for such
>> uses.
>>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: scoping inside a block
Next Topic: Best PHP Training | PHP Development Training | PHP Training Institute
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 23:50:48 GMT 2024

Total time taken to generate the page: 0.04008 seconds