Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling PHP email 2

Status
Not open for further replies.

MHUK

Programmer
Nov 30, 2002
139
GB
Hi
I'm trying to enable PHP email using my computer at home.

I've created a basic form that records a user's name and a text box for their comments/query, and a submit button to email their comments to a specified email address. When the user hits the submit button the name of the user is passed to a page that states "Thank you for your message 'name of user' ".

I have two files:
- an html file that contains the basic form for the user to enter their data and
- a php file that receives the name of the user and outputs it to the screen, and also php code that deals with the sending of the comments to a specified email address.

When the submit button is pressed the output of the user's name works correctly. However, I also come up with an error that says it cant connect - and it states a line of the code where the error is occuring. The error is relating to the mail() function in the php code. I am always connected to the internet and have my firewall turned off, but the same error occurs.

I believe the reason why it cant connect may be the fact the php.ini file isn't configured properly for the [mail function]. I am using my local pc at home and when I go to look at the [mail function] it is currently set to:
SMTP=localhost ;for win32 only
sendmail_from=me@localhost.com ;for win32 only

Is this correct?

Or should it be related to what my ISP is on my computer at home? My ISP is BTinternet. I have tried a possible alternative for the "SMTP" value:
SMTP=smtp.btinternet.com

But I am unsure about the "sendmail_from" value. Should it be something like "username for my isp"@btinternet.com or my actual home email address, for example my_email@btinternet.com?

Thank you for any help.
MHUK
 
"sendmail_from" is the "From": email address used in outgoing mail from Win32 boxes. But you should be able to override that with SMTP headers.

"SMTP" should be set to "localhost" if you are running an SMTP server on the same box that PHP is running on. Otherwise, it should be the IP address or resolvable fully-qualified domain name of the SMTP server you use.
Want the best answers? Ask the best questions: TANSTAAFL!
 
I'd like to write a similar script, which will run on a webserver... can the mail() function handle attachments from the user's computer?

Rose/Miros
 
Yeah, if you upload the file to the server and then learn MIME encoding so that you can attach that file to the email before you call the mail function. It shouldn't be too hard to do. //Daniel
 
That's the core of my problem, getting the user's files to the server, along with various bits of descriptive text from the form. We don't want to allow the users to have ftp access to the server, so they can't upload the files themselves. I was thinking they could attach the files to an email generated by the form...

My "concept" of the form: (Underscores are entry fields. {} are push buttons)

Path to zip file: ____________________ [Browse]
Path to screenshot: _____________________ [Browse]
Descriptive text: _____________________________
_____________________________
_____________________________
_____________________________
[Submit] [Reset]

But it is nice to know that files already on the server can be emailed as attachments... that solves a different problem!

Rose/Miros
 
if al you want to do is get users files onto an ftp server, why not get php to upload it to the server??

do a search for fopen() on php.net, and it should show you how :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top