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.
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 have been researching this topic as i have been having some difficulties send email using my php script. When i execute my contactform.php it executes send_form_email.php and that basically says the email has been sent. There is nothing wrong with my scripts since i had a friend that is code test it on his server he was able to submit the form and generate an email.
So now i went through the steps of configuring the sendmail.ini and the php.ini i believe i am configuring it right according to online tutorials. I have also tested this on my aws server which is on the internet and has disabled the firewall so all ports are open and still unable to send the email through my php scripts. I will post the example of what i am using to configure my .ini files.
So now i am left with creating an mail server. Not too sure of what my options are. I was thinking a relay mail server that would take on the work load and i would not need to go through the hassle of deploying a mail server. Then i have Mercury on the xampp to configure but cannot find a decent tutorial out there that can help me. So i am here asking for professional advice how should i tackle this issue. In my gmail i have enabled everything so all traffic using pop3, imap, and smtp can send and receive just not too sure what i can do. I have never deployed an email server so i am looking for something very easy to use. This is for a small project that i am going to end up doing away with.
https://shellcreeper.com/enable-send-email-in-xampp/
php.ini from:
[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 = "\"\XAMPP\sendmail\sendmail.exe\" -t"
To:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = {your gmail username}#gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
Sendmail.ini
from:
smtp_server=localhost
smtp_port=25
to:
;smtp_server=localhost
;smtp_port=25
and add this in the bottom of your sendmail,ini:
;new config:
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
pop3_server=
pop3_username=
pop3_password=
force_recipient=
hostname=
auth_username={your gmail username}#gmail.com
auth_password={your gmail password}
force_sender={your gmail username}#gmail.com
You could try an SMTP for the time being and use Google mail to send emails.... Here's information on setting it up:
SMTP server (i.e., outgoing mail): smtp.gmail.com
SMTP username: Your full Gmail or Google Apps email address (e.g. example#gmail.com or example#yourdomain.com)
SMTP password: Your Gmail or Google Apps email password
SMTP port: 465
SMTP TLS/SSL required: yes
In order to store a copy of outgoing emails in your Gmail or Google Apps Sent folder, log into your Gmail or Google Apps email Settings and:
Click on the Forwarding/IMAP tab and scroll down to the IMAP Access section: IMAP must be enabled in order for emails to be properly copied to your sent folder.
https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server
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
So this topic does touch both programming + server world, makes more sense to post it here than serverfault.com..
My postfix server is set up to handle mail differently for each domain on the server, however each domain uses the same IP. So, when mail goes out, postfix is unable to track rev IP correctly to determine the correct domain / transport route.
So next option: some how having PHP include a header or smtp setting to say that this mail is coming from "domain.tld"; and postfix determining the route based on that.
So far, I haven't been able to figure it out yet, some fresh brains on this question would be nice.
Take a look at php.ini file /etc/php5/apache2/php.ini on debian:
[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
Uncomment sendmail_from: and set it to your needs.
Make sure you do:
service apache2 restart
or
service httpd restart
to change take effect.
Hope it helps,
Mirko
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