Jump to content

Send email function()


selath
 Share

Recommended Posts

Im having a problem with respect to sending out emails using XAMPP as my local server.

 

After some resarches and videos... I found out that the mail function doesn't work automatically with local web Servers such as (xampp, wampp. ampps .... and all other kind of "amppss out there!").

 

I know that in order to the function work properly i have to reformat some php.ini and sandmail.ini files in the root of my server.

 

My question is : Is there any other way of doing this ? i mean using the mail() function with my local server ON ?

 

Do i really have to buy a server in order to use this ?

 

oh! there's also this guy on youtube that discovered a tool called "Test mail server tool". here's the link if you're interested: http://www.toolheap.com/test-mail-server-tool/

 

What basically this tool allows us to do is:

  • it will catch any email that are sent from the mail function and display them in a textEditor.

 

And that would be fine for me since i just want to test. But that tool doesn't work for windows 8.1 -.-

 

So im getting a little bit frustaded over this

 

Any advice on what i should do ?

 

Thank you

 

Maybe the problem is in my code ?

 

<?php                 $to = 'example1@example.com';$subject = 'this is the subject';$header =' from: $email';$name = $_POST['name'];$email = $_POST['email'];$message = $_POST['message'];    $body = <<<EMAIL    Person name: $name    Person Email: $email    $message     From: $name     EMAIL;if($_POST){    if($name ==''|| $email=='' || $message==''){        $feedback='feed back message';    }else{        mail($to, $subject, $body, $header);        $feedback = ' feedback message';    }    }                   ?>
Edited by selath
Link to comment
Share on other sites

If you want to test that locally then you need to install a mail server, things like XAMPP do not include a mail server. There are several free mail servers you can install and configure so that PHP will work with it, but you might also have a problem if your ISP blocks outgoing mail ports. Some ISPs will block those ports if you have a regular home account instead of a business account.

Link to comment
Share on other sites

  • 3 weeks later...

i got this working myself after a bit of time yesterday.!!i have emails sending thru smtp of my gmail account. (cound not get hotmail working)On 64-Bit Windows 8 running Xamppyou will need to do 4 things.Make A Gmail account we will use there smtp to send out emails.Nex install program called Stunnel (MANDITORY MAKES IT ALL WORK): https://www.stunnel.org/downloads.htmlNext open up php.ini for xammp make changes below serch for "[mail function]" set following:

[mail function]; XAMPP: Comment out this if you want to work with an SMTP Server like MercurySMTP=localhostsmtp_port=465; For Win32 only.; http://php.net/sendmail-from;sendmail_from = postmaster@localhost;sendmail_from = YOUREMAIL; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:program filesC:xampp) fakemail and mailtodisk do not work correctly.; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:sendmail) and use this for sendmail_path.  ; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)sendmail_path = ""C:xamppsendmailsendmail.exe" -t"; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:xamppmailoutput folder;sendmail_path="C:xamppmailtodiskmailtodisk.exe"; 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 filenamemail.add_x_header=Off; Log all mail() calls including the full path of the script, line #, to address and headers;mail.log = "C:xamppphplogsphp_mail.log"

now go into "C:/Xampp/sendmail" and open sendmail.ini edit bellow replacing ur User and pasword

[sendmail]; you must change mail.mydomain.com to your smtp server,; or to IIS's "pickup" directory.  (generally C:InetpubmailrootPickup); emails delivered via IIS's pickup directory cause sendmail to; run quicker, but you won't get error messages back to the calling; application.smtp_server=localhost; smtp port (normally 25)smtp_port=25; SMTPS (SSL) support;   auto = use SSL for port 465, otherwise try to use TLS;   ssl  = alway use SSL;   tls  = always use TLS;   none = never try to use SSLsmtp_ssl=none; the default domain for this server will be read from the registry; this will be appended to email addresses when one isn't provided; if you want to override the value in the registry, uncomment and modify;default_domain=mydomain.com; log smtp errors to error.log (defaults to same directory as sendmail.exe); uncomment to enable loggingerror_logfile=error.log; create debug log as debug.log (defaults to same directory as sendmail.exe); uncomment to enable debugging;debug_logfile=debug.log; if your smtp server requires authentication, modify the following two linesauth_username=YOUREMAILauth_password=YOURPASSWORD; if your smtp server uses pop3 before smtp authentication, modify the ; following three lines.  do not enable unless it is required.;pop3_server=;pop3_username=;pop3_password=; force the sender to always be the following email address; this will only affect the "MAIL FROM" command, it won't modify ; the "From: " header of the message content;force_sender=; force the sender to always be the following email address; this will only affect the "RCTP TO" command, it won't modify ; the "To: " header of the message content;force_recipient=; sendmail will use your hostname and your default_domain in the ehlo/helo; smtp greeting.  you can manually set the ehlo/helo name if requiredhostname=

now restart ur xammp (apache server)

 

Edited by coolshrimp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...