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
Related
The following settings within /etc/php/7.0/apache2/php.ini for mail are marked for Win32 only, but setting them appears to work fine on Ubuntu 16.04 / Apache 2.4.18:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = mail.mymailhost.org
; http://php.net/smtp-port
smtp_port = 25
My system mail (sendmail) log also confirms that mail is able to be sent successfully. Can someone explain why these settings are allowed to be used on Linux hosts? Should I be setting them elsewhere?
So, I have read that these settings are forwarded to sendmail, and the details of relaying the mail to the the SMTP host are handled there. So these settings don't seemed to be ignored on Linux systems, just handed off elsewhere to be dealt with.
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.
In php.ini I set:
SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = mygmail#gmail.com
In my sendmail.ini:
smtp_server=smtp.gmail.com
smtp_ssl=ssl
auth_username=mygmail#gmail.com
auth_password=mygmail password
In my error log:
13/05/18 23:33:30 : Socket Error # 10060<EOL>Connection timed out.
The email actually sent twice, but 99% of the time, I get the same error as above. I disabled my router's SPI, and my computer's firewall. Any ideas?
Most local boxes with Windows don't come with a SMTP server. You could use an external SMTP server and configure it in your php.ini file, but SMTP authentication is not possible.
I recommend you to use PHPMailer, is a simple and flexible PHP Class, that can use a SMTP server with authentication. It is also more secure than using bundled PHP mail() function.
http://phpmailer.worxware.com/
I have config gmail as a local SMTP mail client. I have use host as smtp.gmail.com, my gmail address as username and its password and 587 as port. But i didnt see any emails send from. I have also uncomment the following lines in php.ini
[mail function] For Win32 only.
http://php.net/smtp SMTP = localhost
http://php.net/smtp-port smtp_port =
587
; For Win32 only.
http://php.net/sendmail-from
sendmail_from = myemail#gmail.com
What am i missing please? I am using windows7 x64. I have notice the php.ini says for windows 32 only? is there a another settings for windows x64?
Thanks.
here you have got full tutorial explaining how to achieve this
http://digiex.net/guides-reviews/guides-tutorials/application-guides/544-configuring-php-under-windows-use-gmail-external-smtp-server-ssl.html
there is also great class that I'd recommend for sending e-mails PHPMailer:
tutorial here
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.