send email from xampp? mercury mail server? relay mail server? - php

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

Related

php.ini, sendmail configuration to send an email using a php script

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

php send mail local not woking?

I tried to send mail in localhost.
but working.
i change the php.ini
[mail function]
SMTP=SMTP.gmail.com
smtp_port =587
sendmail_from =postmaster#testmail.com
sendmail_path = "C: \xampp\sendmail.exe\" -t"
this my php mail function
public function sendMail($to,$subject,$from=null,$headers = null)
{
if($headers == null) {
$headers = $this->setMimes();
}
$headers .= $this->setFrom($from);
return mail($to,$subject,$this->getMessage(),$headers);
}
this mail not sending.
To check/change your PHP mail configuration:
Open your php.ini file (if you don't know where this is, see below) Search for the line that reads [mail function] Add/change the details of your mail server. This could be a local mail server or the mail server of your ISP. Save/close the php.ini file Restart your web server
An example of what the mail settings could look like when you first open the php.ini file:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me#example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
Additional info is in echoing phpinfo() you can view your PHP configuration details. You can do this by creating a .php file with the following line on it: . When you run this in your browser, you will see a full list of PHP configuration variables. Simply search for the lines that contain php.ini and sendmail_path to see the values you need to use.
Another idea is you might use ini_set() to properly config your mail setting like this
Add the following code to the top of your email script if your mail script continues to fail.
// Please specify your Mail Server - Example: mail.example.com.
ini_set("SMTP","mail.example.com");
// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");
// Please specify the return address to use
ini_set('sendmail_from', 'example#YourDomain.com');

I can't receive email send from my server

I use apache, php, and sendmail.exe on my Windows.
I download sendmail.exe and configure it like this:
; configuration for fake sendmail
; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail
[sendmail]
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=587
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
default_domain=domain.com
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
;debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username=admin#whilgeek.com
auth_password=19910610
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines
pop3_server=
pop3_username=
pop3_password=
; to force the sender to always be the following email address, uncomment and
; populate with a valid email address. this will only affect the "MAIL FROM"
; command, it won't modify the "From: " header of the message content
force_sender=webmaster#domain.com
; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required
;hostname=
and the email function in my php.ini is like this:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = admin#whilgeek.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path =C:\usr\lib\sendmail.exe -t
; 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 =
I use userCake1.4( download form here ) in my computer and it says sent email successfully. But I didn't receive the email sent to my gamil.
What't wrong?
I think your problem is reverse DNS lookup. When you send an email from a server, your server has to be connected to the internet and the reverse DNS lookup has to point back to your server.
For example, an address (A) record for mail.example.com points to the IP address 192.0.2.5. In pointer records of the reverse database, this IP address is stored as the domain name 5.2.0.192.in-addr.arpa pointing back to its designated host name mail.example.com.
See http://en.wikipedia.org/wiki/Reverse_DNS_lookup

config gmail as a local mail client

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

How to setup mail in XAMPP locally?

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.

Categories