I upgraded Windows XAMPP to 1.8.3 and am trying to get php working (again) on localhost with Apache 2.4.4, Mercury Mail 4.6, and Thunderbird client 24.1.1. Thunderbird can send and receive mail between two accounts. php's mail() is returning true but no mail is coming through.
php.ini is set to listen on port 25.
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost (I've also tried 127.0.0.1)
smtp_port = 25
Any ideas what I might be missing? Thanks in advance.
Note: sendmail.ini also has
smtp_server=localhost
smtp_port=25
I commented out the following line and it worked.
; sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"
For good measure, I changed this to:
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
I don't know why mailtodisk.exe is defaulted to being used, but it appears this simply writes the mail to a folder and it doesn't get delivered.
Related
I can send an e-mail using php mail function. Other languages also have similar functions.
mail(to,subject,message,headers,parameters)
I was under an impression that to send an e-mail you need SMTP credentials. How does this function send emails? Which SMTP server does it use? How does it work?
In php.ini, there is a field called SMTP. It is where you set the SMTP server. I think it defaults to localhost. Other related fields include smtp_port and sendmail_from. You use these for a Win32 system.
you have to configure your server to send emails ..
You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP.
So if you are using XAMPP then you can easily send mail from localhost.
for example you can configure C:\xampp\php\php.ini and c:\xampp\sendmail\sendmail.ini for gmail to send mail.
in C:\xampp\php\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.
in php.ini file find [mail function] and change
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id#gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id#gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id#gmail.com
Now you have done!! create php file with mail function and send mail from localhost.
PS: don't forgot to replace my-gmail-id and my-gmail-password in above code.
Also, don't forget to remove duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" in the php.ini file
REF : LINK
The PHP mail() function usually sends via a local mail server, typically fronted by a sendmail binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server.
Using the mail() function can be a lot of work. Instead use an external library which greatly simplifies this work for you. One such example is PHPMailer
I need some help. I am trying to send an email from a php script. My environment comprises of the following:
Operating System: Windows 8
XAMPP version: 1.8.2
php version: 5.4.19
I have the following php script:
<?php
mail('sugar.donkey#gmail.com','Helo','This is a test','From:salt#goodness.com');
?>
The following configuration on send mail configuration file:
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=465
auth_username=sugar.donkey+gmail.com
auth_password=[MYPASSWORDHERE]
The configurations on php.ini:
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = smtp.gmail.com
; smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster#localhost
I dont get error when I run the php script, but I also dont seem to receive an email. Where am I going wrong ?
I am not sure what os you are running on your webserver, however;
Most Linux installations have sendmail preinstalled, there is always a hassle of setting up SPF/PTR records, to ensure that the email sent by your PHP script is not flagged as spam. A SMTP client called MSMTP can be used to send emails using third-party SMTP servers, this can also be used by PHP's mail() in the place of sendmail.
I hope this helps
https://www.digitalocean.com/community/articles/how-to-use-gmail-or-yahoo-with-php-mail-function
Also for localhost testing, check this out.
http://blogs.bigfish.tv/adam/2009/12/03/setup-a-testing-mail-server-using-php-on-mac-os-x/
Even I am trying to get this configuration work :)
in your case i believe you need to comment out in php.ini
the configuration should be
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
http://php.net/sendmail-from
sendmail_from = postmaster#localhost
Thank you
Ive been trying desperately all day to get an email sent from a php file running on xampp from a gmail account.
I want to use Gmails SMTP as I tried forever to get Mercury to work and it was very problematic. So far I set it up as described below:
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
smtp_ssl=auto
auth_username=justinharr6#gmail.com
auth_password=*password*
force_sender=justinharr#gmail.com
[mail function]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header = Off
(everything else commented out)
Keep in mind this is one of many configurations I have tried none of which work. My php files is returning true from the Mail call but its never getting to the destination. Any help would be greatly appreciated.
i am assuming you are trying to send a mail through local host
i suggest you should use PHP mailer class
I'm learning PHP and have installed XAMPP on my computer.
But I have a problem with the setup as the email option doesn't seem to be working.
After doing some reading I think it has something to do with the below, found on my server in the php.ini file
[mail function]
; For Win32 only.
; *hp://*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
Is there anything I need to change? I have seen software such as swiftmailer mentioned but I don't know if XAMPP has this included already?
My favorite smtp server is hMailServer.
It has a nice windows friendly installer and wizard. Hands down the easiest mail server I've ever setup.
It can proxy through your gmail/yahoo/etc account or send email directly.
Once it is installed, email in xampp just works with no config changes.
XAMPP should have come with a "fake" sendmail program. In that case, you can use sendmail as well:
[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.
Unless you have a mail server set up on your local computer, setting SMTP = localhost won't have any effect.
In days gone by (long ago), it was sufficient to set the value of SMTP to the address of your ISP's SMTP server. This now rarely works because most ISPs insist on authentication with a username and password. However, the PHP mail() function doesn't support SMTP authentication. It's designed to work directly with the mail transport agent of the local server.
You either need to set up a local mail server or to use a PHP classs that supports SMTP authentication, such as Zend_Mail or PHPMailer. The simplest solution, however, is to upload your mail processing script to your remote server.
I use the latest WAMP and I get this when I try to send emails:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\main\createaccount.php on line 8
Message delivery failed...
The message:
$to = "xxx#hotmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
Do you need do download a "mailserver" also?
Please help.
This works for me and should work for you: Use Fake Sendmail and a webhost mail server (i.e. - Godaddy, 1and1, etc.).
1.) Download the sendmail zip and extract it to C:\Wamp\bin\sendmail (for purposes of this example).
2.) Edit C:\wamp\bin\sendmail\sendmail.ini and set the following to your mail server's requirements (mine are below):
smtp_server=mail.yourdomain.com
smtp_port=26
smtp_ssl=none
;default_domain=yourdomain.com
auth_username=smtpuser#yourdomain.com
auth_password=smtppassword
;pop3_server=
;pop3_username=
;pop3_password=
;force_sender=
;force_recipient=
3.) Set the path of sendmail.exe in your php.ini file.
[mail function]
; For Win32 only.
SMTP =
; For Win32 only.
sendmail_from =
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\wamp\bin\sendmail\sendmail.exe -t"
4.) Restart Wampserver.
You might have success using Gmail, but there are a few extra tweaks to make it work. I prefer using the mail server of the webhost where I upload my code.
You are not running an smtp server on your machine, but you don't have to. Just set SMTP to a open smtp server for example:
ini_set('SMTP', 'smtp.yourisp.com');
Take a look at your ISP's home page or http://www.e-eeasy.com/SMTPServerList.aspx for list of SMTP servers.
If you have a desktop mail program, you can use the same address as you use for outgoing mail.
I think your mail server (SMTP) outgoing mail server is not configured in your php.ini file.
Have a look at this:
http://email.about.com/od/emailprogrammingtips/qt/Configure_PHP_to_Use_a_Remote_SMTP_Server_for_Sending_Mail.htm
Also hotmail doesn't allow you to use their mailservers. You should use yahoo or gmail.
Are you sure these servers have a mail program installed on them? If not, that's your problem. For example, XAMPP comes with a mail program called Mercury which you must start before you can send mail through the server.
Follow this article, it works if you have a gmail account.
or at least any email account in which you know the server, port and this stuff.
Send Email From localhost
here is another solution - WAMP send Mail using SMTP localhost
KEEP IN MIND, everytime, after You change php.ini,
you must restart wamp (! ! !)
p.s. in php.ini, i have used:
SMTP = localhost
smtp_port = 25
sendmail_from = your_user#gmail.com
or if oyu cant edit php.ini, try to insert these lines in your php script.
ini_set("SMTP", "localhost");
ini_set("smtp_port", "25");
ini_set("sendmail_from", "your_user#gmail.com");