Jump to content

Recommended Posts

Hi everyone,

 

I am a beginner. I've got a trouble with two php file. There is a form for vistors to fill out. After pressing the submit button, I'm supposed to receive their info. via email. I, however, haven't received  any email. It used to be worked, but it does not work somehow. I tested it myself; I can get the  "thank you for submitting..." message, but I haven't received any email. :confused: I am having Redhat + php + apache. Please help. Thank you so much....

 

The code of the form

<html xml:lang="en" lang="en">

<head>

<title></title>

<link rel="stylesheet" type="text/css" href="styles.css" />

</head>

<body>

<h1>Contact Us</h1>

<form id="submitform" action="processform.php" method="post">

<fieldset>

<legend>Your Information</legend>

<label for="fname">First Name:</label>

<input id="fname" name="fname" type="text" />

<label for="lname">Last Name:</label>

<input id="lname" name="lname" type="text" />

<label for="email">Your Email:</label>

<input id="email" name="email" type="text" />

<label for="dayphone">Day Phone Number:</label>

<input id="dayphone" name="dayphone" type="text" />

<label for="nightphone">Night Phone Number:</label>

<input id="nightphone" name="nightphone" type="text" />

</fieldset>

<fieldset>

<legend>Comment or Question</legend>

<textarea id="comment" name="comment"></textarea>

</fieldset>

<div class="centertxt">

<input name="submitbtn" type="submit" value="Send it!" /></div>

</form>

</body>

</html>

 

Form process file

 

<?php

$fullname = $_POST['fname']." ".$_POST['lname'];

$emailaddress = $_POST['email'];

$daytimephone = $_POST['dayphone'];

$nighttimephone = $_POST['nightphone'];

$fullcomment = $_POST['comment'];

 

$msg = "A new comment has been submitted.\n" .

"Name: $fullname\n" .

"Day time phone number: $daytimephone\n" .

"Night time phone number: $nighttimephone\n" .

"Your comment: $fullcomment";

 

$subject = "Comment from web site";

$email = "$emailaddress";

// Change the value of the $to variable to match the email address

// that should receive the comment emails.

$to = "alreadychanged@alreadychanged.com";

 

ini_set("SMTP","mailserv.alreadychanged.com");

 

mail($to, $subject, $msg, 'From:'.$email);

?>

<html xml:lang="en" lang="en">

<head>

<title></title>

</head>

<body>

<?php

echo "<strong>$fullname, thank you for submitting your comment.</strong>";

echo "You will soon receive more information from us.";

?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/196557-never-receive-email/
Share on other sites

Look into sendmail http://www.sendmail.org

 

Also a good tutorial on how to do it:

http://www.redhat.com/magazine/025nov06/features/email/index.html

 

Note: you are going to need your own domain to do this.  I haven't because I don't have one.

Link to comment
https://forums.phpfreaks.com/topic/196557-never-receive-email/#findComment-1032011
Share on other sites

No I haven't setup mail server on Linux server. I also deleted the smtp ini and it did not help either. Thanks thorpe

 

You need a mail server to be able to send mail.

 

Sorry...I actually don't know if the mail server is setup or not. I just take over the project and I am a beginner of Linux. All I know is the Linux server hosts the website and performs the web data transfer function. If the email server is essential to send email, I believe that it was setup already, but it does not work somehow. How do I check if there is email server on Linux? Thank you very much...

Link to comment
https://forums.phpfreaks.com/topic/196557-never-receive-email/#findComment-1032024
Share on other sites

How do I check if there is email server on Linux?

 

Take a look for sendmail.

 

# whereis sendmail

I checked Sendmail and it is working (ps -aux | grep sendmail).  I added the user, smmsp. The smmsp group is already existed.

After I added the user, smmsp, then I typed, cat /etc/passwd | grep smmsp

 

it shows below:

smmsp:x:504:504::/home/smmsp:/bin/bash(what does that mean?)

 

I also restart sendmail - /etc/init.d/sendmail restart

 

but it takes a  really long time(over 5 mins) . Is this normal to take that long? Then I pressed Ctrl + C to stop it. I'm not sure if sendmail restart successfully or not. By now, I still can't send email via the web form. Please help

Link to comment
https://forums.phpfreaks.com/topic/196557-never-receive-email/#findComment-1032053
Share on other sites

Can't you just use some code like this:

<?php

$email = $_POST['email'];
$name = $_POST['name'];
$subject = $_POST['subject'];
$message = $_POST['message'];

mail( "whatever@something.com, $subject, $name $message, "From: $email" );

?>

 

Thats what i always use. I never have any problems  :)

 

Link to comment
https://forums.phpfreaks.com/topic/196557-never-receive-email/#findComment-1032071
Share on other sites

My maillog:

 

Mar 21 05:00:01 pe-web sendmail[29834]: o2KL01g29834: from=root, size=327, class=0, nrcpts=1, msgid=<201003202100.o2KL01g29834@pe-web.org>, relay=root@localhost

Mar 21 05:00:01 pe-web sendmail[29834]: o2KL01g29834: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30327, dsn=2.0.0, stat=Sent

Mar 22 05:00:00 pe-web sendmail[7234]: o2LL00d07234: from=root, size=327, class=0, nrcpts=1, msgid=<201003212100.o2LL00d07234@pe-web.org>, relay=root@localhost

Mar 22 05:00:00 pe-web sendmail[7234]: o2LL00d07234: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30327, dsn=2.0.0, stat=Sent

Mar 23 05:00:00 pe-web sendmail[675]: o2ML00D00675: from=root, size=327, class=0, nrcpts=1, msgid=<201003222100.o2ML00D00675@pe-web.org>, relay=root@localhost

Mar 23 05:00:00 pe-web sendmail[675]: o2ML00D00675: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30327, dsn=2.0.0, stat=Sent

Mar 24 05:00:01 pe-web sendmail[30858]: o2NL00H30858: from=root, size=327, class=0, nrcpts=1, msgid=<201003232100.o2NL00H30858@pe-web.org>, relay=root@localhost

Mar 24 05:00:01 pe-web sendmail[30858]: o2NL00H30858: to=root, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:00, mailer=local, pri=30327, dsn=2.0.0, stat=Sent

Mar 24 15:21:58 pe-web sendmail[7419]: o2O7LwN07419: from=nobody, size=370, class=0, nrcpts=1, msgid=<201003240721.o2O7LwN07419@pe-web.org>, relay=nobody@localhost

Mar 24 15:22:03 pe-web sendmail[7421]: o2O7LwN07419: to=test <123@yahoo.com>, ctladdr=nobody (99/99), delay=00:00:05, xdelay=00:00:05, mailer=esmtp, pri=30370, relay=c.mx.mail.yahoo.com. [206.190.54.127], dsn=5.0.0, stat=Service unavailable

Mar 24 15:22:03 pe-web sendmail[7421]: o2O7LwN07419: o2O7M3M07421: DSN: Service unavailable

Mar 24 15:22:03 pe-web sendmail[7421]: o2O7M3M07421: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30470, dsn=2.0.0, stat=Sent

Mar 25 05:00:00 pe-web sendmail[16003]: o2OL00O16003: from=root, size=327, class=0, nrcpts=1, msgid=<201003242100.o2OL00O16003@pe-web.org>, relay=root@localhost

Mar 25 05:00:00 pe-web sendmail[16003]: o2OL00O16003: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30327, dsn=2.0.0, stat=Sent

Mar 25 10:00:49 pe-web sendmail[825]: alias database /etc/aliases rebuilt by root

Mar 25 10:00:49 pe-web sendmail[825]: /etc/aliases: 40 aliases, longest 10 bytes, 395 bytes total

Mar 25 10:00:49 pe-web sendmail[835]: starting daemon (8.11.2): SMTP+queueing@01:00:00

Mar 25 11:13:40 pe-web sendmail[2648]: o2P3Den02648: from=nobody, size=227, class=0, nrcpts=1, msgid=<201003250313.o2P3Den02648@pe-web.org>, relay=nobody@localhost

Mar 25 11:13:42 pe-web sendmail[2650]: o2P3Den02648: to=mingbb57@hotmail.com, ctladdr=nobody (99/99), delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=30227, relay=mx1.hotmail.com. [65.54.188.94], dsn=2.0.0, stat=Sent ( <201003250313.o2P3Den02648@pe-web.org> Queued mail for delivery)

Mar 25 16:00:40 pe-web sendmail[8099]: o2P80e108099: from=nobody, size=360, class=0, nrcpts=1, msgid=<201003250800.o2P80e108099@pe-web.org>, relay=nobody@localhost

Mar 25 16:00:41 pe-web sendmail[8101]: o2P80e108099: to=peweb@cuhk.edu.hk, ctladdr=nobody (99/99), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=30360, relay=cwemgw3.itsc.cuhk.edu.hk. [137.189.4.20], dsn=2.0.0, stat=Sent (ok:  Message 84816988 accepted)

Mar 25 16:06:43 pe-web sendmail[8166]: o2P86hC08166: from=nobody, size=329, class=0, nrcpts=1, msgid=<201003250806.o2P86hC08166@pe-web.org>, relay=nobody@localhost

Mar 25 16:06:44 pe-web sendmail[8168]: o2P86hC08166: to=peweb@cuhk.edu.hk, ctladdr=nobody (99/99), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=30329, relay=cwemgw2.itsc.cuhk.edu.hk. [137.189.4.19], dsn=2.0.0, stat=Sent (ok:  Message 145390500 accepted)

Mar 26 05:00:00 pe-web sendmail[23795]: o2PL00R23795: from=root, size=327, class=0, nrcpts=1, msgid=<201003252100.o2PL00R23795@pe-web.org>, relay=root@localhost

Mar 26 05:00:01 pe-web sendmail[23795]: o2PL00R23795: to=root, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=local, pri=30327, dsn=2.0.0, stat=Sent

Mar 26 09:24:12 pe-web sendmail[24651]: o2Q1OC124651: from=nobody, size=197, class=0, nrcpts=1, msgid=<201003260124.o2Q1OC124651@pe-web.org>, relay=nobody@localhost

Mar 26 09:24:13 pe-web sendmail[24653]: o2Q1OC124651: to=cchance@cuhk.edu.hk, ctladdr=nobody (99/99), delay=00:00:01, xdelay=00:00:00, mailer=esmtp, pri=30197, relay=cwemgw2.itsc.cuhk.edu.hk. [137.189.4.19], dsn=2.0.0, stat=Sent (ok:  Message 145459550 accepted)

Mar 26 10:16:48 pe-web sendmail[25459]: o2Q2GmZ25459: from=nobody, size=199, class=0, nrcpts=1, msgid=<201003260216.o2Q2GmZ25459@pe-web.org>, relay=nobody@localhost

Mar 26 10:16:48 pe-web sendmail[25461]: o2Q2GmZ25459: to=cchance@cuhk.edu.hk, ctladdr=nobody (99/99), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=30199, relay=cwemgw1.itsc.cuhk.edu.hk. [137.189.4.18], dsn=2.0.0, stat=Sent (ok:  Message 173213852 accepted)

 

Link to comment
https://forums.phpfreaks.com/topic/196557-never-receive-email/#findComment-1032100
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.