Member Avatar for James singizi

hello, im using a wamp server and i want to sent an email and after writting the code, im getting an error that says 'warning: mail() [function.mail]: failed to connect to mail server at localhost port 25, verify your SMTP and smtp_port setting in php.ini or use ini_set().'
Im not familiar with the php.ini file so i need help to fix this error.

Member Avatar for LastMitch

@James singizi

warning: mail() [function.mail]: failed to connect to mail server at localhost port 25, verify your SMTP and smtp_port setting in php.ini or use ini_set().'

It means look in your php.ini for the SMTP.

In order to use the mail() function you must setup the php.ini parameters correctly.

Another words, you have to setup the SMTP correctly on your php.ini.

If you don't understand just post the code

I mean your mail() function and your php.ini code

Member Avatar for James singizi

my php.ini is as follows:
[mail function];
For win 32 only.
SMTP=localhost
smtp_port = 25;
For win 32 only.
Sendmail_from=you@yourdomain

commented: It will works for localhost with out ssl connection +2

I didn't think you could set up a local server with email unless you have an email client to handle this.
you could try setting it in your email file code: phpini_set("sendmail_from", "info@mydomain.com"). I heard this works

Member Avatar for James singizi

i have tried this and it didnt work, im still getting the same error

Member Avatar for LastMitch

@James singizi

i have tried this and it didnt work, im still getting the same error

my php.ini is as follows:
[mail function];
For win 32 only.
SMTP=localhost
smtp_port = 25;
For win 32 only.
Sendmail_from=you@yourdomain

There's nothing wrong with the code. I think you don't SMTP server installed on your server.

You can used phpmailer or Pear Mail package or swiftmailer

So your PHP installed has invalid mail settings because it wasn't configuring correctly so that's why it didn't work.

Install either package from above, just installed only one and test it out and it will work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.