0

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?

4
Contributors
10
Replies
69
Views
2 Years
Discussion Span
Last Post by dayanadolce
0

[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

Votes + Comments
Short, Sweet, Accurate, 3of3
0

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
0

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...

0

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

0

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

0

i don't find

extension=php_openssl.dll

in php.ini . am i suppose just add the

extension=php_openssl.dll

into the code?

Edited by dayanadolce: grammar

0

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

0

@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

Edited by almostbob

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.