Mail help please!

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Mail help please!

Postby M@ster » 09. March 2010 06:30

I recently download Xampp which I love, everything works amazingly however I can't get phps mail() function to work at all. I've changed the php.ini file around so many times. I've tried connecting it to smtp.googlemail.com, smtp.gmail.com, smtp.aol.com, localhost and a million other things. I've changed the port a million times, tried auth_username and what not.

I'm completely stuck I have no idea where to go and how to get it to work if anyone can please provide instructions that would be extremely helpful as I haven't had any luck with other forums.
M@ster
 
Posts: 2
Joined: 09. March 2010 06:24

Re: Mail help please!

Postby Nobbie » 09. March 2010 10:46

Sending mails is not an easy thing. You must have quite a knowledge how mailservers are working.

The PHP mail()-function supplys only a very simple API in order to send mail via SMTP servers that do *not* require any authorization. Unfortunately, all public SMTP servers (like smtp.gmail.com etc.) require authorization, therefore you *cannot* send mails directly via mail() using these public servers.

If you supply "localhost" as SMTP server, you must (of course) install a local SMTP server, for example Mercury. For the same reason, you must not configure it using any authorization. Mercury comes in several flavours, one of them is a real SMTP server, but usually most mail boxes block mails coming from privat IPs (like yours), these IPs are blacklisted due to SPAM reasons. Therefore it is not usefull to run Mercury as a real SMTP server. Instead, you may install Mercury as a "Relay SMTP" client, which simply relays all mails to a public SMTP server (like smtp.gmail.com). The big difference between using Mercury (and relaying mails to a public SMTP server) and directly sending mails to the public server is, that you have the opportunity to provide username and password for the public SMTP server when you use the Mercury Relay SMTP client. The authorization is not done by PHP (as it cannot authorize), but by Mercury. PHP only send the all mails to the local Mercury, and Mercury does "the real job". You need a mail account at Google (for example) in order to configure Mercury sending all mails to the Google SMTP Server.

There is another way of doing quite the same, it is called the "fake sendmail.exe" program. Instead of using Mercury, you may configure php.ini to use the sendmail.exe program (instead of using SMTP) which comes with Xampp, and (same as for using Mercury Relay SMTP), you have to configure sendmail.exe (as far as I know there is a sendmail.ini somewhere) to send all mails to a public SMTP server (i.e. smtp.gmail.com) using the userid and password for authorization which can be configured in sendmail.ini.

Last not least, you may avoid using the PHP mail() function, there is powerfull PHPmailer class, which provides lots of powerfull features, like

a) send email via authorized SMTP
b) send HTML emails
c) send Attachments (like pictures and music files)
d) ... and many more

and this class can be downloaded from http://sourceforge.net/projects/phpmailer/files/

If you use this class to send mail, you dont need to configure any third party software, as this class uses standard PHP socket functions instead.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Mail help please!

Postby M@ster » 09. March 2010 18:27

I've tried using sendmail.exe and haven't had much luck with it. I'm not 100% sure what I'm doing.

Lets say my email at gmail.com is: [name]@gmail.com
And my password is: [password]

How do I set up my sendmail.ini and my php.ini so that it will use it via sendmail.exe. I am using Xampp version 1.7.3 and my sendmail.ini file has nothing in it yet (its completely empty).

Thanks for the replies!
M@ster
 
Posts: 2
Joined: 09. March 2010 06:24

Re: Mail help please!

Postby CraigS » 11. March 2010 01:33

If you are using gmail you are required to use SSL authentication, by default sendmail does not allow this, what i have found needs to be done is you need to get an smtp -ssl forwarder, i found a great tutorial here that worked perfectly for me, even though it was using a completely different php program.


http://www.projectpier.org/node/817


Hope this points you in the right direction

Craig S
User avatar
CraigS
 
Posts: 16
Joined: 10. March 2010 23:37
Location: Wisconsin, USA

Re: Mail help please!

Postby wkelvinf » 15. March 2010 06:42

@Nobbie: It seems as if before using the phpmailer class, one *still* needs a local SMTP server

@Master: I have exactly the same problem like you. I have configure my php.ini and sendmail.ini but it still doesn't work

@Craig S: I have done everything in that tutorial still to no avail. I installed stunnel, it seems to be working very well, I also installed Projectpier and configured my php.ini and sendmail.ini but I still don't get to see any emails in my gmail box.
Others have tried to no avail.

I have all the "tools" needed to setup this stuff but I still can't figure out why its not working.
wkelvinf
 
Posts: 8
Joined: 13. March 2010 14:16

Re: Mail help please!

Postby Nobbie » 15. March 2010 11:24

M@ster wrote:I I am using Xampp version 1.7.3 and my sendmail.ini file has nothing in it yet (its completely empty).


Very strange, because I installed Xampp 1.7.3 and just edited sendmail.ini "out of the box" - and it is NOT empty, it is preconfigered with some handy examples.

I have an email account at googlemail.com (don't know what's the difference to gmail.com) and I immediately succeded in sending mails from my local PC via googlemail.com

Let's assume me email account is "myuser@googlemail.com" and my password is "mypassword". Also assume that Xampp is installed in C:\xampp (as recommended for all Windows systems). This is the contents of sendmail.ini (replace user and password by your values):

Code: Select all
# 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 Gmail
tls on
tls_certcheck off
host smtp.googlemail.com
from myuser@googlemail.com
auth on
user myuser@googlemail.com
password mypassword

# Set a default account
account default : Gmail


You don't need the "Mercury" account (and you me delete that lines, but they were part of my standard sendmail.ini and I did not change them).

As "Craig" points out, googlemail.com needs "SSL", what is not quite right (is it TLS, but many people call it "SSL" instead). Fortunately, TLS is supported by sendmail (see the "tls" Commands in sendmail.ini) and this setting works with googlemail.com.

Finally, you have to edit php.ini and to activate the sendmail.exe. Therefore you must comment out the SMTP and smtp_port directives, instead we use the sendmail_path directive. This is the mail section how it looks now:
Code: Select all
[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 = postmaster@localhost

; 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"


Ignore the "For Unix only" statement, as this is Ok for Windows as well!

If you did not install Xampp to c:/xampp, beware that the pathname does not contain any spaces (like c:\program files\xampp). In that case, you have to supply the sendmail_path in a different way:

Code: Select all
sendmail_path = "\"C:/program files/xampp/sendmail/sendmail.exe\" -t"


Now restart Apache.

This works perfectly for me, but remind, that all mails you are sending via PHP now are coming "From: myuser@googlemail.com" (you cannot supply a different FROM: clause, even if you do so, it's overwritten).
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: Mail help please!

Postby wkelvinf » 15. March 2010 22:49

Wow. This is my second day on this stuff but still no sucess. I have followed all the steps as above but...
There seems to be 2 php.ini files in the xampp folder. One in C:\xampp\apache\bin\php.ini, another in C:\xampp\php\php.ini. My default seems to be the one in the php folder because I initial configured but the one in the apache folder and I was getting an error message while trying to send a mail with mail().

After adjusting all the php.ini files as described above, I no longer got any errors but I never got to receive any mail.
I even tried debugging using phpinfo() but the HTTP Header carried no information relating to a message which means the email wasn't sent all.

I also used another software to monitor any smtp traffic but there was no traffic at all meaning that for some reason, the mail is not being sent.

Unfortunately, I still can't figure out the problem.
I also tried using Hotmail but ...

I read somewhere to uncomment extension=php_smtp.dll (in php.ini) but still no success.

Anyway, I will try this very stuff tomorrow on my friend's computer and see
wkelvinf
 
Posts: 8
Joined: 13. March 2010 14:16

Re: Mail help please!

Postby wkelvinf » 18. March 2010 21:25

I have finally solved the problem :D . I was tipped off to "telnet smtp.gmail.com 25" and I got an error.
I tried to telnet my University mail server and it worked :o . I later found out that my university (which is actually my ISP) has blocked all traffic via port 25 with external mail servers.
So I configured the sendmail.ini using my ISP mail server and it worked :D

I also later found out that communication with external mail servers is allowed on port 587. So I configure Gmail again and added "port 587" in the sendmail.ini and it also worked :D

That's it at last :D . After 5 days :(
wkelvinf
 
Posts: 8
Joined: 13. March 2010 14:16

Re: Mail help please!

Postby vanesns » 08. April 2010 18:38

Hi All! I'm a beginner in Xampp and have an issue with Mercury Mail. If I check the box svc for this in Xampp's Control Panel, I got the same result if you, but I think I don't need this!
My matter is I can't to active SMTP service! In Control Panel, Mercury is running, and I configure parameters to use my e-mail in Mercury/32 and change parameters on files php.ini and sendmail.ini, but it doesn't work, because in Xampp Status, I got "SMTP Service DEACTIVATED". Another thing I haven't a line with extension "php_smtp.dll" in my "php.in" and a dll file in my php/ext folder... I don't know what I do :o !! Can you help me?? Thanks a lot!! :roll:
vanesns
 
Posts: 3
Joined: 08. April 2010 18:01

Re: Mail help please!

Postby wkelvinf » 12. April 2010 21:11

vanesns wrote:Hi All! I'm a beginner in Xampp and have an issue with Mercury Mail. If I check the box svc for this in Xampp's Control Panel, I got the same result if you, but I think I don't need this!
My matter is I can't to active SMTP service! In Control Panel, Mercury is running, and I configure parameters to use my e-mail in Mercury/32 and change parameters on files php.ini and sendmail.ini, but it doesn't work, because in Xampp Status, I got "SMTP Service DEACTIVATED". Another thing I haven't a line with extension "php_smtp.dll" in my "php.in" and a dll file in my php/ext folder... I don't know what I do :o !! Can you help me?? Thanks a lot!! :roll:


Have you followed all the steps mentioned above? You don't need to use Mercury. Simply configure the sendmail.ini file as suggested above, then configure your php.ini file and it should work. Make sure you use your ISP mail server. If you want to use an external mail server, find out the exact port allowed by your ISP
wkelvinf
 
Posts: 8
Joined: 13. March 2010 14:16

Re: Mail help please!

Postby WilliL » 12. April 2010 21:45

I've got problems with Mercury server. After deactivating module X (blocks port 25?) it works fine.
Cofiguration - ProtcolModules - deactivate MercuryX
Willi
WilliL
 
Posts: 660
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: Mail help please!

Postby sharpnova » 14. April 2010 00:03

I've tried all of this but haven't been able to make use of PHP's mail function either.

I'm using an otherwise completely operational XAMPP installation.

I use Time Warner Cable in the Grand Prairie area (mid cities in between Dallas and Fort Worth) and am using GoDaddy as my DNS provider.

I haven't been able to get SMTP or sendmail to produce any results. (haven't been able to send any mails yet)

Is there anything I need to configure with my DNS for a mail server to work? (I'm guessing no)

Which mailserver should I be using? TimeWarner's website wasn't very helpful in this regard. (I'm guessing smtp-server.tx.rr.com)

Do I even need to be specifying a mailserver if I'm using sendmail?

Also, do I need to have Mercury enabled if I'm using sendmail? If so, what settings do I need to configure?



I really know nothing about any of this stuff so this has been quite a challenge!
sharpnova
 
Posts: 15
Joined: 05. March 2009 23:29

Re: Mail help please!

Postby wkelvinf » 14. April 2010 07:27

sharpnova wrote:I've tried all of this but haven't been able to make use of PHP's mail function either.

I'm using an otherwise completely operational XAMPP installation.

I use Time Warner Cable in the Grand Prairie area (mid cities in between Dallas and Fort Worth) and am using GoDaddy as my DNS provider.

I haven't been able to get SMTP or sendmail to produce any results. (haven't been able to send any mails yet)

Is there anything I need to configure with my DNS for a mail server to work? (I'm guessing no)

Which mailserver should I be using? TimeWarner's website wasn't very helpful in this regard. (I'm guessing smtp-server.tx.rr.com)

Do I even need to be specifying a mailserver if I'm using sendmail?

Also, do I need to have Mercury enabled if I'm using sendmail? If so, what settings do I need to configure?



I really know nothing about any of this stuff so this has been quite a challenge!


It took me a very long time to successfully configure xampp to send mails. There are basically just two files to configure.
The sendmail.ini (in the sendmail folder) and php.ini (in the php folder).
To configure the sendmail.ini you need to know the outgoing mail server of your ISP (the company you get your Internet connection from) or the allowed port number for external mail servers like gmail or hotmail. Contact your Internet Provider to get these infos.
Once you have these parameters, configure the sendmail.ini as already mentioned above. Note that if you are using an external mail server, you will have to specify the port. E.g
Code: Select all
# sendmail.ini

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# An external mail server: Gmail
account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
port 587
from yourusername@gmail.com
auth on
user yourusername@gmail.com
password yourpassword

# Set a default account
account default : Gmail


The next step is to go ahead and configure the php.ini file (as mentioned above).
Restart apache and try sending the mail again. A log file will be created in the sendmail folder. You can check out this log file to see if the mail was successfully sent or not.
wkelvinf
 
Posts: 8
Joined: 13. March 2010 14:16

Re: Mail help please!

Postby sharpnova » 16. April 2010 22:34

Thank you. simply copied and pasted your sendmail.ini and modified the appropriate fields. (and fixed an error in the php page that is testing this)

Here's my sendmail.ini

Code: Select all
# sendmail.ini

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# An external mail server: Gmail
account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
port 587
from myemail@gmail.com
auth on
user myemail@gmail.com
password mygmailpassword

# Set a default account
account default : Gmail


here is my php.ini

Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = smtp-server.tx.rr.com
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = admin@mydomain.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"
SMTP = localhost
smtp_port = 587

; 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 = "C:\xampp\apache\logs\php_mail.log"


Mercury is off. I'm assuming that doesn't need to be on.

Here is the php code I am using to test this.

Code: Select all
<?php
   mail( "myemail@gmail.com", "Email Subject", "hello", "From: myemail@gmail.com" );
?>
sharpnova
 
Posts: 15
Joined: 05. March 2009 23:29

Re: Mail help please!

Postby Nobbie » 16. April 2010 23:21

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
SMTP = localhost
smtp_port = 587


This is nonsense, EITHER use sendmail_path OR SMTP + smtp_port. There is no such wrong example in this thread.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 108 guests