View previous topic :: View next topic |
Author |
Message |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Mon Jun 07, 2004 11:15 pm Post subject: mail() question |
|
|
I just copied and bit of code out of a book that I am reading about php and using the mail() option. When I ran the html and php code I got this error message.
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in D:\PROGRAM FILES\ABYSS WEB SERVER\htdocs\do_sendfeedback.php on line 10
Here is the php code that I am using.
<?php
$msg = "Sender's Full Name:\t$_POST[sender_name]\n";
$msg .= "Sender''s E-Mail:\t$_POST[sender_email]\n";
$msg .= "Did you like the Site:\t$_POST[like_site]\n";
$msg .= "Additional Message:\t$_POST[message]\n\n";
$mailheaders = "From My Web Site <lmdcwd@juno.com>\n";
$mailheaders .= "Reply-To $sender_email\n\n";
mail("lmdcwd@juno.com", "Feedback Form", $msg, $mailheaders);
echo "<h1 align=center>Thank You, $_POST[sender_name]</h1>";
echo "<p align=center> We appreciate your feedback.</p>";
?>
But I am not to sure what change is needed in the php.ini fill if any.
Any sugestions? |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Tue Jun 08, 2004 12:40 am Post subject: |
|
|
Well you don't have either the "From:" header or the php.ini, so we're going to have to change one.
It is easy to change the php.ini, but this is global (every message you send using a script will be from this address).
Anyway, just open php.ini with notepad and either go to line 614, or search for "sendmail_from." _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Tue Jun 08, 2004 3:36 am Post subject: mail() |
|
|
Ok I changed to sendmail_from and made it = my e-mail address. I asume that is what should have been changed. Can I also asume that for it to work even in the testing stage I need to be loged on to the internet?
Is there some place where I can find more info on all of the changes that can be made in php.ini file. |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Tue Jun 08, 2004 4:00 am Post subject: |
|
|
First, you made the right change. Second, yes you need to be connected to the internet, and third, visit www.php.net to check out the php.ini file (or just read the comments in the file itself). _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Tue Jun 08, 2004 2:56 pm Post subject: mail() |
|
|
Ok it is still not working. maybe I mist something. Here is all my code
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Feedback</title>
</head>
<form method="POST" action="do_sendfeedback.php">
<p>Your Name: <input type="text" name="sender_name" size=30></p>
<p>Your E-Mail Address: <input type="text" name="sender_email" size=30></p>
<p>Did you like this site?
<input type="radio" name="like_site" value="yes" checked> yes
<input type="radio" name="like_site" valu="no"> no
</p>
<p> Additional Message: <br>
<textarea name="message" cols=30 rows=5></textarea>
</p>
<input type="submit" value="Send This Form">
</form>
<body>
</body>
</html>
<?php
$msg = "Sender's Full Name:\t$_POST[sender_name]\n";
$msg .= "Sender''s E-Mail:\t$_POST[sender_email]\n";
$msg .= "Did you like the Site:\t$_POST[like_site]\n";
$msg .= "Additional Message:\t$_POST[message]\n\n";
$mailheaders = "From My Web Site <lmdcwd@juno.com>\n";
$mailheaders .= "Reply-To $sender_email\n\n";
mail("lmdcwd@juno.com", "Feedback Form", $msg, $mailheaders);
echo "<h1 align=center>Thank You, $_POST[sender_name]</h1>";
echo "<p align=center> We appreciate your feedback.</p>";
?>
and the sendmail_from now says sendmail_from = "lmdcwd@juno.com"
I connected to the internet and reran the code (both of them) and I am still getting this error message
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in D:\PROGRAM FILES\ABYSS WEB SERVER\htdocs\do_sendfeedback.php on line 10
Is there something wrong with line 10 that I am not seeing? |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Tue Jun 08, 2004 11:48 pm Post subject: |
|
|
Is line 10 the "?>" mark?
Make sure the line you put the email address in isn't commented (in the php.ini file), otherwise, I'm out of ideas. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Wed Jun 09, 2004 3:29 am Post subject: mail() |
|
|
Ok This is line 10
mail("lmdcwd@juno.com", "Feedback Form", $msg, $mailheaders);
And this is what I Changed in the php.ini
[mail function]
; For Win32 only.
SMTP=localhost
; For Win32 only.
;sendmail_from=lmdcwd@juno.com
I added the lmdcwd@juno.com |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Wed Jun 09, 2004 4:30 am Post subject: |
|
|
Wow... My last idea was actually correct. The line is commented. Remove the semicolon from the front of it.
EDIT: Oh, and do you have a mail/SMTP server set up? _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Wed Jun 09, 2004 3:44 pm Post subject: mail() |
|
|
Ok now that I have removed to semicolon I am getting a different error.
It is
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\PROGRAM FILES\ABYSS WEB SERVER\htdocs\do_sendfeedback.php on line 10
And yes I am using a mail/smtp I thank. I am using outlook express 6.
Is there something else that needs to be set in the php.ini file. |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Wed Jun 09, 2004 5:12 pm Post subject: |
|
|
Outlook Express is an email client, not an SMTP/POP server. You need to edit your php.ini file so the SMTP/POP settings are the same as the settings you use to send mail in Outlook Express. |
|
Back to top |
|
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Wed Jun 09, 2004 10:44 pm Post subject: mail() |
|
|
Ok I have changed it so that it now looks like this
[mail function]
; For Win32 only.
SMTP=mail.softHome.net
; For Win32 only.
sendmail_from=cwdlmdd@softHome.net
I have changed the e-mail so that it matches the smtp website.
But I am now getting a time out error telling me that the page can not be displayed.
I am using a firewall and it is asking me for permission before it tries to send the e-mail and I do give it but than I am getting the time out. It is giving me an HTTP 500 server error.
Could it be the mail.softhome.net site it is still in bata testing
I guess I am getting closer |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
|
Back to top |
|
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Thu Jun 10, 2004 4:34 am Post subject: mail() |
|
|
Ok I have changed the time out time to 60 Sec. and now it is giving me this error message
Warning: mail(): Failed to connect to mailserver at "mail.softHome.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\PROGRAM FILES\ABYSS WEB SERVER\htdocs\do_sendfeedback.php on line 10 |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Fri Jun 11, 2004 12:43 am Post subject: |
|
|
Search for "SMTP" and "smtp_port" and configure them accordingly. Remember to remove any comments. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Fri Jun 11, 2004 3:56 am Post subject: mail() |
|
|
That is what I though also, but when I searched for SMTP I olny came up with
SMTP=mail.softHome.net and if search for smpt_port I get a message that it can't find it. I even tried searching for just port and only came up with word that have port in it. No smtp_port.
Can I add it in the php.ini file? |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Fri Jun 11, 2004 4:00 am Post subject: |
|
|
Yes, you can add the entry if you want.
Also, an option might be to reinstall PHP. When you install it, it asks for your SMTP server and email address, and if you enter it correctly, PHP will most likely do the configuration for you. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Sat Jun 12, 2004 5:10 am Post subject: mail() |
|
|
I think I am getting closer!!
I am now getting this error
Warning: mail(): SMTP server response: 552 You must authenticate via SMTP AUTH or you must POP first. See http://SoftHome.net/help/popfirst.html . in D:\PROGRAM FILES\ABYSS WEB SERVER\htdocs\do_sendfeedback.php on line 10
I am not sure what they are saying (SMTP AUTH) though.
Apparently when I cleared out my email account that I was trying to send the for info to and freed up some space. It begain working. So I think I finally have it working.
But I am still not sure what SMPT AUTH is about. |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sat Jun 12, 2004 6:52 am Post subject: |
|
|
SMTP Authentication: (I use this on my mail server). It prevents against relaying from unverified senders and receivers. When you log on to your SMTP Server, you can specify a username and password to authenticate you. The other option is POP before SMTP. If you log in to the POP mail account, then you can use the SMTP server to send a message for around 30 minutes. The reason this started working when you checked your email is because POP before SMTP verified you and then you were able to send email. Of course if you had tried to send a message around 30-45 minutes after you last checked your email, it might not have worked.
I can explain what SMTP Auth is, however I can't seem to find any configuration in the php.ini. It looks like you're going to have to integrate it into the script. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Sat Jun 12, 2004 3:05 pm Post subject: mail() |
|
|
I would like to Thank You for all of your help!!! Everyone here has been very helpful.
And of cource the more I get into this the more questions I am having. But I will try a few ideas first and see it they will work before asking.
I do have one more question though.
When I get this form that I am going to make set up and on my hosting service. will I have to resetup the php.ini that I will be using on the host server or will they do that for me? |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sat Jun 12, 2004 9:59 pm Post subject: |
|
|
You are saying you are going to switch to a professional hosting service? If you are, then you can most likely use the UNIX Sendmail utility instead of SMTP. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Sun Jun 13, 2004 4:09 am Post subject: mail() |
|
|
I guess that you can say that I am. When I finish the web site for them. It will be hosted where ever they chose. Although I will more than likely try and talk them into using the one that I use. Which offers PHP along with many other server side programming lang.
I have never done any server side programming so I am not sure who or how it gets setup with the hosting service.
What I was trying to do with that php program was learn PHP and try to make sure what I was learning would work. So now I can apply what I have learned to the website that I am making.
I hope that all makes some since! |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sun Jun 13, 2004 4:52 am Post subject: |
|
|
So your making a website for someone, and they get to choose where to host it, correct? _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Sun Jun 13, 2004 5:01 am Post subject: mail() |
|
|
Yes. It is for my church. They already have a website and this is something special for the employment ministy. So there is a good chance that it may just be added to the existing website. But I am trying to convince them that they should have a site of there own. But it may become a matter of money. the employment ministy dose not have any money support from the church.
So I am not really sure what is going to happen there yet (when it comes to where the site will be hosted).
They hold meeting once a month for the unemployed member of the church and I am presently unemployed and became involved with this project.
So all I can to is try and be prepared for what ever they chose. |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sun Jun 13, 2004 6:48 am Post subject: |
|
|
You can host a website for $2 a month if you choose. When it comes to hosting, there isn't really a lot of cost involved, because there are so many different hosting companies. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Mon Jun 14, 2004 4:31 am Post subject: mail() |
|
|
Ok Thanks for the info about hosting. Can someone recomend anyone special?
My next step.
Can someone give me the tag that would let me redirecte them back to a serton page after they submit the for info and it has been processed through the php code.
Do I just do that with html code to direct them when the submit button is pressed? |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Mon Jun 14, 2004 4:56 am Post subject: Re: mail() |
|
|
cwdlmdd wrote: | Ok Thanks for the info about hosting. Can someone recomend anyone special? |
[url=1and1.com]1&1[/url] is good, but they have bad support.
It would be pretty easy to echo a redirecting javascript. http://javascriptkit.com _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Tue Jun 15, 2004 6:38 pm Post subject: mail() |
|
|
Ok I have created my form and the php that goes with it and I am getting an error that says
Notice: Undefined index: Letter in D:\PROGRAM FILES\ABYSS WEB SERVER\htdocs\FBCH Employment\form.php on line 15
Can someone what is ment my Undefined index and is there a place that will tell me what the error mean?
here is the php code
<?php
$msg = "Sender's Full Name:\t$_POST[Contact_FullName]\n";
$msg .= "Sender's Tital:\t$_POST[Contact_Title]\n";
$msg .= "Sender's Address:\t$_POST[Contact_StreetAddress]\n";
$msg .= "Sender's Address2:\t$_POST[Contact_Address2]\n";
$msg .= "Sender's City:\t$_POST[Contact_City]\n";
$msg .= "Sender's State:\t$_POST[Contact_State]\n";
$msg .= "Sender's Zip Code:\t$_POST[Contact_ZipCode]\n";
$msg .= "Sender's Work Phone:\t$_POST[Contact_WorkPhone]\n";
$msg .= "Sender's Home Phone:\t$_POST[Contact_HomePhone]\n";
$msg .= "Sender's Fax Number:\t$_POST[Contact_FAX]\n";
$msg .= "Sender's E-Mail:\t$_POST[Contact_Email]\n";
$msg .= "Sender's Job catagory:|t$_POST[Job_Category]\n";
$msg .= "Sender's Resume:\t$_POST[Resume]\n";
$msg = "Sender's Cover Letter:\t$_POST[Letter]\n"; This is the line that is giving me problems.
$mailheaders = "From Employment Ministry <lmdcwd@juno.com>\n";
$mailheaders .= "Reply-To $Contact_FullName\n\n";
header("location:http://127.0.0.1/FBCH%20Employment/test.htm");
mail("lmdcwd@juno.com", "Feedback Form", $msg, $mailheaders);
?> |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Tue Jun 15, 2004 9:08 pm Post subject: |
|
|
Are you sure you have a textbox with the name "Letter?" _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Tue Jun 15, 2004 11:00 pm Post subject: mail() |
|
|
Yes That is what is so puzzeling. I actually have two textbox One is name resume and the other is named Letter. Here is the text for the Letter. Maybe you can see something I can't.
<P>
Cover Letter in text format</P>
<BLOCKQUOTE>
<P>
<TEXTAREA NAME="Letter" ROWS=5 COLS=35></TEXTAREA>
<BR>
</P>
I am a little confused on what the problem could be! |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Tue Jun 15, 2004 11:55 pm Post subject: |
|
|
Hmm... I see nothing wrong. Maybe you can post the other textbox, and we can compare. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Wed Jun 16, 2004 3:57 am Post subject: mail() |
|
|
Here is the other textbox code.
<P>
Enter Resume in text format</P>
<BLOCKQUOTE>
<P>
<TEXTAREA NAME="Resume" ROWS=5 COLS=35></TEXTAREA>
<BR>
</P>
Is there a limit on the amout of text that can be input into a textbox? Could that be it?
When I ran the test of the form, I put in a resume in the resume textboc and a cover letter in the letter textbox. Could the cover letter text just be to big for the size of the textbox. Whould that give me the error? |
|
Back to top |
|
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Wed Jun 16, 2004 4:11 am Post subject: mail() |
|
|
I am really confused now. I just the info that I was entering in the resume and letter textboxes and when I received the info in my email all I had was the info in the letter textbox and none of the other information.
I don't understand what is going on. I did not make any changes at all to the php file or the form just the data that I entered into the form.
Here are both textboxes;
<P>
Enter Resume in text format</P>
<BLOCKQUOTE>
<P>
<TEXTAREA NAME="Resume" ROWS=5 COLS=35></TEXTAREA>
<BR>
</P>
</BLOCKQUOTE>
<P>
Cover Letter in text format</P>
<BLOCKQUOTE>
<P>
<TEXTAREA NAME="Letter" ROWS=5 COLS=35></TEXTAREA>
<BR>
</P>
and here is the php code
<?php
$msg = "Sender's Full Name:\t$_POST[Contact_FullName]\n";
$msg .= "Sender's Tital:\t$_POST[Contact_Title]\n";
$msg .= "Sender's Address:\t$_POST[Contact_StreetAddress]\n";
$msg .= "Sender's Address2:\t$_POST[Contact_Address2]\n";
$msg .= "Sender's City:\t$_POST[Contact_City]\n";
$msg .= "Sender's State:\t$_POST[Contact_State]\n";
$msg .= "Sender's Zip Code:\t$_POST[Contact_ZipCode]\n";
$msg .= "Sender's Work Phone:\t$_POST[Contact_WorkPhone]\n";
$msg .= "Sender's Home Phone:\t$_POST[Contact_HomePhone]\n";
$msg .= "Sender's Fax Number:\t$_POST[Contact_FAX]\n";
$msg .= "Sender's E-Mail:\t$_POST[Contact_Email]\n";
$msg .= "Sender's Job catagory:|t$_POST[Job_Category]\n";
$msg .= "Sender's Resume:\t$_POST[Resume]\n";
$msg .= "Sender's Cover Letter:\t$_POST[Letter]\n";
$mailheaders = "From Employment Ministry <lmdcwd@juno.com>\n";
$mailheaders .= "Reply-To $Contact_FullName\n\n";
mail("lmdcwd@juno.com", "Feedback Form", $msg, $mailheaders);
header("location:http://127.0.0.1/FBCH%20Employment/test.htm");
?> |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Wed Jun 16, 2004 4:30 am Post subject: |
|
|
First, your Header location is 127.0.0.1. You know that only works on your computer, right?
Second, change Sender's to Sender\'s in each message part. Third, instead of $_POST[name], use $_POST['name'] with the apostrophes. These may help, and they may not, but you might as well give them a try. _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Wed Jun 16, 2004 4:35 am Post subject: mail() |
|
|
Ok I tried that and it did not change anything. But when I just typed in a small amount of text in the textbox it seemed to work. And that is what I though about the 127.0.0.1. |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Jun 17, 2004 10:33 am Post subject: |
|
|
iNaNimAtE wrote: | First, your Header location is 127.0.0.1. You know that only works on your computer, right? |
In other words, it is not a good idea to write full URLs because the Location header you wrote will fail to give the expected result on other computers (it will only work on your computer.)
It is highly preferred to use URLs relative to your root path. So replace:
Code: | header("location:http://127.0.0.1/FBCH%20Employment/test.htm"); |
with
Code: | header("location:/FBCH%20Employment/test.htm"); |
Now it will work independently from the computer which is browsing your site. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
|