Forum Moderators: coopster
When I tried if mail can be sent it showed me this error ..
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 D:\xampp\htdocs\project\m_pro_edit.php on line 174
Can this be done offline by modifying some settings ? or is it possible only after hosting it on a server ?
Thank you
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25; For Win32 only.
;sendmail_from = me@example.com; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = "D:\xampp\sendmail\sendmail.exe -t"; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
But I dont know what to make of it.. I tried removing the first semi colon .. but it doesnt seem to work
I am quite new to PHP
I am calling the mail() function this way
mail($to, $subject, $msg, 'From:' . $from);
where $from is already set as "myname@domain.com"
BTW I dont havent registered a domain yet... this I am doing over XAMPP. Still using myname@domain.com which is fake!
Can you please shed some more light on how this works? I mean suppose I define a fake id .. then will it still send the mail..
conversely, if I set the value to some other persons email id, then does it mean i can send mail using his id without his knowledge..
Sorry if these questions are dumb!
As far as your error... XAMPP on Windows uses SMTP which is the same mechanism that your email client uses to send email. So what you need to do is set
SMTP = same host that you use in your email client
This can be either your ISP's SMTP server or your web host's SMTP server, just copy the settings that you use in your usual email client.
I also asked my coach why it wasn't working. His explanation was, that Wampserver - and perhaps XXAMP is the same - hasn't a mailserver running under localhost.
When it would be uploaded to my webhost it would work (hasn't checked that yet).
I also asked my coach why it wasn't working. His explanation was, that Wampserver - and perhaps XXAMP is the same - hasn't a mailserver running under localhost.
Yes, but XAMPP does come with Mercury Mail which can be enabled for this purpose - I assume.
But to enable mail() to be able to send email you don't necessarily need Mercury Mail. As idfer suggests above, just edit the SMTP, smtp_port and sendmail_from settings in php.ini. After editing php.ini you need to restart Apache. You might also need to edit your firewall settings. This should work OK under a test environment on Windows.