Help - complete novice trying to send emails from localhost

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dapa
Forum Newbie
Posts: 9
Joined: Fri Nov 10, 2006 3:10 pm

Help - complete novice trying to send emails from localhost

Post by dapa »

Please can anyone help before I walk away from php?

I am trying to test sending an email from a simple form however I am having no success as I recieve the following error messge;

Warning: mail() [function.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 C:\wamp\www\experiment\CONTACT_FORM_RESPONSE.php on line 40

I have tried to amend the php.ini file but I am not too confident that I have done it correctly.

Please could someone tell me in plain english what I lines I need to change in the php.ini file?

Thanks
dapa
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you need to point it to a valid smtp server. obviously you do not have a mail server set up on the web server.
dapa
Forum Newbie
Posts: 9
Joined: Fri Nov 10, 2006 3:10 pm

Post by dapa »

Burrito wrote:you need to point it to a valid smtp server. obviously you do not have a mail server set up on the web server.
Ok - so how do I point it to a valid smtp server?

Sorry but as I said I am a complete novice :cry:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Search Google for 'Setting up a local SMTP server'.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

change this section in your php.ini

Code: Select all

[mail function]
; For Win32 only.
SMTP = mail.yoursmtpserver.com
smtp_port = 25
you'll need to make sure your smtp server will accept mail from your web server (w/o a log in), or else you're going to need to step up to a different mail solution like swift or something.
dapa
Forum Newbie
Posts: 9
Joined: Fri Nov 10, 2006 3:10 pm

Post by dapa »

Burrito wrote:
you'll need to make sure your smtp server will accept mail from your web server (w/o a log in), or else you're going to need to step up to a different mail solution like swift or something.
Thanks but how can I find out if my smtp server will accept mail from your web server?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

dapa wrote:Thanks but how can I find out if my smtp server will accept mail from your web server?
you could always try it.
dapa
Forum Newbie
Posts: 9
Joined: Fri Nov 10, 2006 3:10 pm

Post by dapa »

Burrito wrote:
dapa wrote:Thanks but how can I find out if my smtp server will accept mail from your web server?
you could always try it.
Tried it but it still will not work.

I've just gone at got Swift but I am more confused now :oops:

What do I do with Swift?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

dapa wrote:What do I do with Swift?
I've never used swift so I can't help you there. We have an entire forum dedicated to it though so any questions you have about it would be answered there.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

What ISP are you with? Your ISP will usually give you an outgoing mail server. The one you'd place in your email client like outlook or thunderbird. It's usually one of (but not limited to):

outgoing.<yourisp>.tld
smtp.<yourisp>.tld
mail.<yourisp>.tld

For example, gmail uses:

smtp.gmail.com

If you have access to a terminal window which can run the DIG command (a linux box will usally suffice) then you can do this:

Say my email was phillip@tiddlywinks.info

I could get the SMTP for it (usually) by running:

dig MX tiddlywinks.info

That returns DNS records for the mail exchangers for tiddlywinks.info

That MX server may only receive incoming mail though so don't count on it, but hopefully you get where I'm coming from.
Post Reply