I have scoured every tutorial out there on how to do this and I am still not getting the desired result so there must be some detail I am missing. The mail() function returns as though it succeeded however I NEVER GET ANY EMAILS in my sent or inbox
In a nutshell I have done the following:
Copied Sendmail.exe and Sendmail.ini along with their dlls to a
folder named Sendmail that resides in c:\program files\wamp\bin\
Edited the sendmail.ini to point to port 465 (for gmail) and smtp to
smtp.gmail.com, also configured the correct user name and password
authentication fields, as well as set smtp_ssl to ssl
Enabled the php_openssl and php_sockets under php extensions in wamp
edited php.ini [mail function] parameters. I commented out everything in win32 and then set smtp_path = c:\program files\wamp\bin\sendmail\sendmail.exe -t" then restarted all serviced on WAMP
Logged into my gmail account and enabled IMAP
Can anyone please help me out here???
This is from : http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/
I followed the steps and was able to send emails from wamp server. Your problem seems to be the name of the folder "Program Files" it has a space in it.
If the path to the sendmail.exe contains “space” (for example, “C:\Program Files\PHP\sendmail\”) then Apache would not be able to locate it. So, either store the sendmail.exe at a “non-spaced” location/path OR write the path in DOS style “C:\Progra~1\PHP\sendmail\” in the php.ini (sendmail_path = "C:\Progra~1\PHP\sendmail\sendmail.exe -t -i").
Have a look at > http://phpmailer.worxware.com/?pg=examplebgmail
and https://github.com/Synchro/PHPMailer
It's a lot easier and it saves a lot of time to send using frameworks rather than attempting to tinker wamp on your own.
(on a side note, it's MUCH easier to send gmail via smtp with python)
Good luck!
Related
My environment is as follows:
-Windows IIS7 + Windows DNS Server (all DNS records and IIS7 settings are fully accessible by me).
-hMailServer with SMTP listening on 25.
I guess that's about it, my actual intentions are as follows:
I want to use WordPress for one of my domains which is pointed to the server, but currently it is unable to send emails (for example password reminders).
My knowledge is not exactly amazing for stuff like this, so be gentle to explain. :>
You have to configure your SMTP settings in the php.ini file (located in the php-directory). If you don't use smtpauth/ssl this will do the trick.
[mail function]
; For Win32 only.
SMTP = 192.168.1.10
; For Win32 only.
sendmail_from = john#example.com
However, the standard php mail function neither supports smtpauth nor ssl. Have a look at the specs.
As you are running windows, you can use fake sendmail. This supports auth and ssl.
Read this guide, and it should work.
I've already set sendmail_path to the path of 'sendmail.exe', but PHP didn't send email. it requires mail server or something.
PHP said can't connect to localhost at port 25. The fun fact in the php.ini file is that above the path to 'sendmail.exe', stated "Unix only!????", but 'sendmail.exe' is Windows executable. [i believe the sendmail.exe i have in XAMPP is windows version of the Unix sendmail, so the comment in php.ini might not be at right place]
I'm just only sending email, not receiving email, so why do i need a mail server (like Mercury)? or the SMTP (the protocol) requires a server for both sending & receiving?
As per my thinking, we can just open the port (usually 25? 465?) of the destination server to send message to. Anything wrong in my procedure here and above?
Just can't find the details in similar Stackoverflow questions so i bring up this matter, please help me get enlightened.
Only because you find a file called sendmail.exe on your computer it does not mean that PHP supports that specific binary out of the box.
From sendmail_path:
[...] This directive works also under Windows. If set, smtp, smtp_port and sendmail_from are ignored and the specified command is executed.
Double check that sendmail.exe on your disk is compatible with PHP.
Try:
sendmail_path = "X:\path\to\sendmail.exe -t"
I'm just only sending email, not receiving email, so why do i need a mail server (like Mercury)? or the SMTP (the protocol) requires a server for both sending & receiving?
You don't need to. It's only likely that the configuration you use with sendmail.exe (that's not the PHP configuration, look for sendmail.ini instead) that you have told sendmail.exe to use an SMTP server.
Either change that, and if sendmail.exe does not provide the feature you're looking for, replace sendmail.exe with something that matches your needs.
It's just that by default it actually makes sense to send emails. So why are you upset about a configuration that makes sense?
See also:
Mock mail on xampp development box
Is there a way that I can configure the WAMP server for PHP to enable the mail() function?
Configuring a working email client from localhost is quite a chore, I have spent hours of frustration attempting it. I'm sure someone more experienced may be able to help, or they may perhaps agree with me.
If you just want to test, here is a great tool for testing mail locally, that requires almost no configuration:
http://www.toolheap.com/test-mail-server-tool/
Install Fake Sendmail (download sendmail.zip).
Then configure C:\wamp\sendmail\sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user#gmail.com
auth_password=your_password
The above will work against a Gmail account.
And then configure php.ini:
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
Now, restart Apache, and that is basically all you need to do.
Using an open source program call Send Mail, you can send via wamp rather easily actually. I'm still setting it up, but here's a great tutorial by jo jordan. Takes less than 2 mins to setup.
Just tried it and it worked like a charm! Once I uncommented the error log and found out that it was stalling on the pop3 authentication, I just removed that and it sent nicely. Best of luck!
You need a SMTP server to send your mail. If you have one available which does not require SMTP authentification (maybe your ISP's?) just edit the 'SMTP' ([mail function]) setting in your php.ini file.
If this is no option because your SMTP server requires authentification you won't be able to use the internal mail() function and have to use some 3rd party class which supports smtp auth. e.g. http://pear.php.net/package/Mail/
I tried Test Mail Server Tool and while it worked great, you still need to open the email on some client.
I found Papercut:
https://github.com/ChangemakerStudios/Papercut-SMTP
(updated URL for 2021)
For configuration it's easy as Test Mail Server Tool (pratically zero-conf), and it also serves as an email client, with views for the Message (great for HTML emails), Headers, Body (to inspect the HTML) and Raw (full unparsed email).
It also has a Sections view, to split up the different media types found in the email.
It has a super clean and friendly UI, a good log viewer and gives you notifications when you receive an email.
I find it perfect, so I just wanted to give my 2c and maybe help someone.
Sendmail wasn't working for me so I used msmtp 1.6.2 w32 and most just followed the instructions at DeveloperSide. Here is a quick rundown of the setup for posterity:
Enabled IMAP access under your Gmail account (the one msmtp is sending emails from)
Enable access for less secure apps. Log into your google account and go here
Edit php.ini, find and change each setting below to reflect the following:
; These are commented out by prefixing a semicolon
;SMTP = localhost
;smtp_port = 25
; Set these paths to where you put your msmtp files.
; I used backslashes in php.ini and it works fine.
; The example in the devside guide uses forwardslashes.
sendmail_path = "C:\wamp64\msmtp\msmtp.exe -d -C C:\wamp64\msmtp\msmtprc.ini -t --read-envelope-from"
mail.log = "C:\wamp64\msmtp\maillog.txt"
Create and edit the file msmtprc.ini in the same directory as your msmtp.exe file as follows, replacing it with your own email and password:
# Default values for all accounts
defaults
tls_certcheck off
# I used forward slashes here and it works.
logfile C:/wamp64/msmtp/msmtplog.txt
account Gmail
host smtp.gmail.com
port 587
auth on
tls on
from ReplaceWithYourEmail#gmail.com
user ReplaceWithYourEmail#gmail.com
password ReplaceWithYourPassword
account default : gmail
I used Mercury/32 and Pegasus Mail to get the mail() functional. It works great too as a mail server if you want an email address ending with your domain name.
I'm currently trying to debug an Elgg-based website (I didn't develop it) and I would like to send the emails directly from local development machine (WinXP). I'm running WAMP with Apache 2.2.11 and PHP 5.3.0
After some searching, the simplest solution that I've come across is using fake sendmail to forward it to my GMail/Google apps account via SMTP and let it do the sending. The problem is that I get no errors whatsoever, but the email isn't being sent.
Here's what I did:
Copied the sendmail.exe and sendmail.ini to a subfolder in WAMP
Configured it via sendmail.ini (the configuration settings are ok)
Edited php.ini to add the path to sendmail.exe
sendmail_path = "C:\Program Files\wamp\bin\sendmail\sendmail.exe -t"
Commented out the windows SMTP settings in php.ini
; SMTP = localhost
; smtp_port = 25
; sendmail_from = xxx#domain.com
; mail.force_extra_parameters =
The mail.log file shows the following:
mail() on [C:\Program Files\wamp\www\mail.php:9]: To: xxx --
Headers: From: xxx Reply-To: xxx X-Mailer: PHP/5.3.0
My guess is that the problem is that the default Windows option (to specify the server and not the sendmail utility) is not overriden. In phpinfo() I still get the SMTP -> localhost and smtp_port -> 25 options, even though I commented them.
If anyone managed to get this working, I'd really appreciate some help. In my opinion, using fake sendmail is a lot simpler than installing a mail server on your machine.
Thanks!
P.S. Please don't suggest PHPMailer and the like, because I have to use the mail() function. That's how Elgg works.
I've gotten it to work eventually. The problem was that PHP had a bug in parsing .ini files with spaces in the path (for sendmail). It was fixed in version 5.3.0, but the manual had no info on this.
So, yes, it is possible to use sendmail with PHP on Windows :D.
Thank you all for your time!
Make sure you have SMTP Service running on your local machine and that SMTP Port(25) is opened.
Have a check on the services (Run->services.msc) and look for Send Mail Transfer
If you cannot find SMTP on the services list, you must install it:
To add,
Run->appwiz.cpl->Add Remove Windows components->IIS->Details->SMTP
I am not sure if this helps or not, what i used to do in these scenarios was to setup , outlook on my machine and have it set to get emails from the pop every 5 mins or so, that way my ip/machine was authenticated against the pop and if i just set the :
SMTP = localhost
smtp_port = 25
in php.ini , the mail function worked fine. So in your case just set your outlook to work with a pop and use that smtp in php.ini and hopefully it should work. I havent tested this will GMail though.
P.S. Please don't suggest PHPMailer and the like, because I have to use the mail() function. That's how Elgg works.
...unless you're using a plugin that changes this behaviour:
http://community.elgg.org/pg/plugins/costelloc/read/16498/phpmailer
I am working on my own website.
I am planning to have a mail function to send notification to the users who want to join my website.
The problem is the mail function of PHP does not work for me.
Can anyone help me with this?
if you are on a windows platform, you could try:
fake sendmail for windows
I am assuming you are not running your own mail server and do not wish to install one. All you want to do is send emails to or via (relay) your ISP mail server using PHP, either to test your own scripts or to test third party ones.
With Fake Sendmail in place we need to edit the php.ini file so PHP’s mail function can use it:
Open the file php.ini located in folder C:\php search for this section [mail function] (starts around line 612)
sendmail_path = "/usr/local/sendmail/sendmail.exe -t"
for more info go to:
http://wiki.uniformserver.com/index.php/Installing_Fake_Sendmail_for_Windows
Modify the php.ini for your application to point to an smtp server in the [mail function] section. The options you need to set are described here: http://www.w3schools.com/PHP/php_ref_mail.asp
In this case, I'd say that if the documentation for mail doesn't answer your question, it's a configuration problem with whatever you are using as a server.
If this is your desktop, you may also be having problems with your mail looking like spam.