hello there. i want to send email but i use localhost. the mail() function does't seems working as it says something is wrong with the port etc.

<?php

$sendmail = (mail('sample@yahoo.com','sample email','sample content','From: from@gmail.com'));

if($sendmail)
{echo "success";
}
else
{echo "unsuccess";}
?>

even the simple email as above cannot be send to the email. it echo success. but the email still has not been received. can you help me with this?

[Install] the "fake sendmail for windows". If you are not using XAMPP you can download it here:http://glob.com.au/sendmail/sendmail.zip
[Modify] the php.ini file to use it (commented out the other lines):

[mail function]
; For Win32 only.
; SMTP = smtp.gmail.com
; smtp_port = 25

; For Win32 only.
; sendmail_from = <e-mail username>@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=<username>
auth_password=<password>
force_sender=<e-mail username>@gmail.com

commented: Short, Sweet, Accurate, 3of3 +13

thank you. for this code.

; For Win32 only.
; SMTP = smtp.gmail.com
; smtp_port = 25

; For Win32 only.
; sendmail_from = <e-mail username>@gmail.com

do i need to remove the semi colon? example :

  For Win32 only.
     SMTP = smtp.gmail.com
     smtp_port = 25

     For Win32 only.
     sendmail_from = <e-mail username>@gmail.com

The semi-colon indicates the line to be commented. So the line starting with For Win32 seems to be a comment line to me. Thus, no need to remove the semi-colon...

in C:\xampp\php\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.
don't forgot to replace my-gmail-id and my-gmail-password in above code

as previous posters have indicated you must install, or fake, a mail server. Local host packages do not include a smtp server or a pop server
Have had good results with imti321's recommendation
It works
Its simple
Its free

when all else fails
RTFM for you wamp xamp lamp stack,
it will tell you what is and isnt installed

i don't find

extension=php_openssl.dll

in php.ini . am i suppose just add the

extension=php_openssl.dll

into the code?

Then go to php and find extention click on the arrow and make sure ssl is tick marked.i have attached a file phpextention.jpg

aaa.jpg

This post has no text-based content.

@imti321,
if the op still won't RTFM even after you gave it the software, abandon its dumb a#s
some people won't help themselves

sorry but thanks for your explaination. i have tried the solution you gave, but it still didn't works. it's alright! i use phpMailer instead. but, it is not user friendly because it declared one fixed sender at at time.

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.