Solved

PHP mail problems

Posted on 2006-11-23
8
373 Views
Last Modified: 2008-02-01
I am developing a website and I have it setup so whenever you register for a new account it sends an email for activation. However when I try to use the mail function I get an error.
I am currently running wamp.

This is the error i get:
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:\home\home_install\wamp\www\Books\register.php on line 64

my php.ini section for the mail function.

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = null

my php code:

$to = $regemail;
$subjust = "activation";
$message = "test message";
mail($to,$subject,$message);
0
Comment
Question by:fanar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Expert Comment

by:RWJDCom
ID: 18004922
The mail system seems like it is trying to connect to a SMTP server on your local machine and it is unable to.  My suggestion would be to use phpmailer which you can find at http://phpmailer.sourceforge.net/ and with that PHP class you are able to set the SMTP server, login, and password.  You will need to have a mail account somewhere with SMTP access and just use that account to send the email out.

Check the documentation of phpmailer on how to do this and if you are still having problems please let me know and I will let you know the exact syntax of what I use.

I hope this helps.

-Jeff
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 18005481
change localhost to the address of your ISPs Outgoing Mail Server or yours if you have one.

PHP has no mail system built in it just calls a standard mail server.
0
 
LVL 6

Expert Comment

by:aescnt
ID: 18005697
RWJDCom, you can also set the SMTP server with just vanilla PHP, in php.ini (like the settings the asker quoted) or with ini_set().
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:RWJDCom
ID: 18005749
Yes, asecnt, but if your SMTP server requires authentaction you can't set that information in the php.ini.  Thats why I recommended phpmailer.

-Jeff
0
 
LVL 8

Expert Comment

by:John Kawakami
ID: 18006782
PEAR::Mail's docs indicate that it supports authentication.
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 18006794
Yes but there is a chance the users server WONT have SMTP authentication if he doesent know what it is then the chances are hes using his ISPs which is liklely to be Open Relay anyway.

Why bother going into setting up PHPMailer when the issue can be resolved quite simply by adding a line to the php.ini. If the user then requires authentication they can look at adapting their code.
0
 
LVL 1

Author Comment

by:fanar
ID: 18008784
how do i find what my ISPs is?
Another question then: once i am done developing it I am moving the website to an actual webhost, do most of them support mail with php?
0
 
LVL 13

Accepted Solution

by:
rhickmott earned 200 total points
ID: 18008805
Yes most web hosts have a outgoing mail server as they are in control of the php set-up and installation you wont have to worry about this you should find the mail() command will just work

Who is your Internet Service Provider? if you look at the mail settings for them they will provide you with an outgoing mail server normally something like smtp.myhost.com. Get this address and place it as the server address in the php.ini and your mail commands should then work.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question