2

I am new to PHP, and am trying to design a site based on php for my college project. I use EasyPHP devServer 14.0. I have a register page, which mails a verification code to the user to his provided email id. For the demo project, I tried to send a mail from localhost to the user's mail Id, But it showed an error message like this:

Warning: mail(): Failed to connect to mailserver at "127.0.0.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

I ve checked for previously existing solutions, but those solutions are for xampp or wamp servers and the php.ini file content differs between the servers. Could Someone Guide me how to configure the php.ini file in EasyPHP server? Could you please illustrate me with some example?

This is what I ve tried, Pardon me, if it seems to be a simple question.

$pmail = " gotfromuser@example.com";
$subject = " email";
$message = "Hello User";
$headers = "From: admin@example.com" . "\r\n" . "CC: user1@example.com";

mail($pmail,$subject,$message,$headers);
Jefree Sujit
  • 1,546
  • 5
  • 22
  • 38
  • duplicate:http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost – Nikhil Supekar Jan 04 '15 at 15:49
  • 1
    @NikhilSupekar, dude, I have previously mentioned in my question, All i could find here is for either wamp server or xampp server, But i want for EasyPHP server, and the php.ini file config differs.. The link u mentioned is for xampp server. please read properly and help me solve this problem... – Jefree Sujit Jan 04 '15 at 15:54
  • All servers provide the same platform, so it shouldn't be a that much problem. Anyway, you just need to install sendmail and configure it's path in your php.ini file. Alternatively, you can use more standard method PHPMailer library, you can also configure your gmail account with it. – Nikhil Supekar Jan 04 '15 at 16:32
  • Hi did you solve this problem? – GeneCode Feb 08 '19 at 06:48

1 Answers1

1

Change your php.ini file like this:

SMTP = smtp.example.com               // Set your SMTP server
smtp_port = 25                        // Set your SMTP port
sendmail_from = me@localhost.com      // Set your sender mailaddress
  • ,Thanks for your guidance, youu ve mentioned smtp.example.com, what should i replace that 'example' with? should i replace it with gmail? i mean, with email provider's server name or with my ISP's server name? – Jefree Sujit Jan 04 '15 at 15:39
  • @JefreeSujit Yes, indeed, for Gmail you need to set `SMTP = smtp.gmail.com` and `smtp_port = 25`. – Gilles Bossuyt Jan 04 '15 at 15:41
  • Here's the reference for configuring SMTP with a gmail account: [link](https://support.google.com/a/answer/176600?hl=en) `SMTP = aspmx.l.google.com` and `SMTP_PORT = 25` works for me... `smtp.gmail.com` seems to require SSL, which you won't have on localhost – strider Nov 07 '15 at 02:22