I'm developing a php application and need to test the functionality of sending emails. Problem is I'm using a development environment (wamp on windows) so I'm guessing I don't have access to smtp or a mail server.
It looks like I may need to install a separate application that would act as my mail server. What's the easiest way to do this (I'm on windows working on wamp), and is there another alternative like a public server to be used for testing by developers (free please because I'll probably use it just 开发者_开发技巧10 times until the email functionality is tweaked). Then I guess there are settings that I need to change to my development environment itself? Anyone can shed some light on this please.
Thanks
XAMPP comes with Mercury to handle E-Mails. It can talk to SMTP servers through SSL if necessary, and works well for me.
You need an SMTP Server. I use PostCast Server, which is free and does the needful.
Have you tried creating fake GMail account and then sending emails through its SMTP server? Here is the example - for me works fine.
http://phpmailer.worxware.com/index.php?pg=exampleagmail
Have you tried PHP function
mail($to, $subject, $body, $headers)
http://php.net/manual/en/function.mail.php
XAMPP comes with a "fake" sendmail program. If you use XAMPP, you can use sendmail as so: (ignore the "For Unix only" warning; it works fine on Windows)
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:/xampp/sendmail/sendmail.exe -t -i"
Sendmail should have a sendmail.ini
with it; it should be configured as so:
# Example for a user configuration file
# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"
# Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off
# A freemail service example
account ACCOUNTNAME_HERE
tls on
tls_certcheck off
host smtp.gmail.com
from EMAIL_HERE
auth on
user EMAIL_HERE
password PASSWORD_HERE
# Set a default account
account default : ACCOUNTNAME_HERE
Of course, replace ACCOUNTNAME_HERE with an arbitrary account name, replace EMAIL_HERE with a valid email (such as a Gmail or Hotmail), and replace PASSWORD_HERE with the password to your email. Now, you should be able to send mail. Remember to restart Apache (from the control panel or the batch files) to allow the changes to PHP to work.
精彩评论