Problem in sending email from localhost

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Problem in sending email from localhost

Post by josh »

Are you trolling?
josh wrote: Use localhost, not mail.google.com
I said that and you reply, "which host should I use, I am using google" :roll:

Either this or you'll need to authenticate with your gmail details, as like I said Google requires authenticated gmail users as the 'mail from' address.
shariefbe
Forum Newbie
Posts: 16
Joined: Thu Jan 20, 2011 12:10 am
Location: Trichy, India

Re: Problem in sending email from localhost

Post by shariefbe »

sorry i am novice. please dont mistake me and see my php.ini

Code: Select all


[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = xxxxxxxx@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"F:\test\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 =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "F:\test\xampp\apache\logs\php_mail.log"
should i use any extra thing to send mail from my localhost. i mean authentication?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Problem in sending email from localhost

Post by josh »

Stop using smtp.google.com and use localhost.
shariefbe
Forum Newbie
Posts: 16
Joined: Thu Jan 20, 2011 12:10 am
Location: Trichy, India

Re: Problem in sending email from localhost

Post by shariefbe »

Yes i now i understood. I used localhost and still i got that error. So i did "telnel localhost 25" in cmd prompt. it tells "connecting to localhost.....Could not open connection to the host, on port 25: connect failed"
Don't know what is wrong. I already using xampp. All are working fine. I can visit my website by localhost. so it shows my server is working. But it is not working when i use telnet?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Problem in sending email from localhost

Post by josh »

shariefbe wrote:Could not open connection to the host, on port 25: connect failed"
This means no program is listening on that port. This is 100% evidence that you do not have a MTA (mail transfer agent) running.

In my experience setting up mail servers on windows is a pain, on linux its much easier. You could try this perl script which will run on windows, it emulates an SMTP server on localhost and just sends the emails to a .txt file on disk. http://www.lastcraft.com/fakemail.php
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Problem in sending email from localhost

Post by John Cartwright »

josh wrote:
shariefbe wrote:Could not open connection to the host, on port 25: connect failed"
This means no program is listening on that port. This is 100% evidence that you do not have a MTA (mail transfer agent) running.

In my experience setting up mail servers on windows is a pain, on linux its much easier. You could try this perl script which will run on windows, it emulates an SMTP server on localhost and just sends the emails to a .txt file on disk. http://www.lastcraft.com/fakemail.php
+1

Otherwise, use your ISP's mailing server.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Problem in sending email from localhost

Post by josh »

The ISP's mail server probably uses outgoing authentication too. If you want to use authentication like your ISP, or gmail... you'll need something above & beyond the mail() function. Look into phpmailer or swift mailer.
shariefbe
Forum Newbie
Posts: 16
Joined: Thu Jan 20, 2011 12:10 am
Location: Trichy, India

Re: Problem in sending email from localhost

Post by shariefbe »

Hi guys. Wonder happens. I got one mail from my localhost. But i dont know in which attempt i got that mail. Because in each and every try I was changing my config file.

Now i dont know in which attempt it works...
Post Reply