Xampp php mail smtp

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?

Читайте также:  Notepad плагины для java

Xampp includes Mercury. Did you set that up? I think the docs also include a chapter about making PHP work with it

3 Answers 3

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.

Hi Byron, are there any tutorials on how to setup hMailserver proxy to send emails to gmail and yahoo ?

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.

Источник

How to Configure XAMPP to Send Email from Localhost with PHP

It is often necessary to configure the XAMPP server for sending email from the localhost using PHP. To meet that goal, you need to make changes to two files such as sendmail.ini and php.ini. Here, we will represent to you what steps you need to take to achieve that.

Steps to Send an Email with the help of XAMPP

Below, you can find the steps to configure XAMPP for sending emails from the local host with PHP.

Step 1: XAMPP Installation Directory

The first step is opening the XAMPP Installation Directory.

Step 2: Go and Open php.ini

The second step is going to C:\xampp\php and opening the php.ini file.

Step 3: Find [mail function]

In the framework of the third step, you should press ctrl + f for finding the [mail function] .

Step 4: Pass Values

Now, it is necessary to detect and pass the values, demonstrated below:

SMTP=smtp.gmail.com smtp_port=587 sendmail_from = [email protected] sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

Step 5: Open sendmail.ini

The next step is going to C:\xampp\sendmail and opening the sendmail.ini file.

Step 6: Find [sendmail]

Press ctrl + f for finding [sendmail] .

Step 7: Search and Pass Values

The seventh step considers searching and passing the values, demonstrated below:

mtp_server=smtp.gmail.com smtp_port=587 error_logfile=error.log debug_logfile=debug.log [email protected] auth_password=Your-Gmail-Password [email protected].com(optional)

Script for Sending Email

Finally, let’s see how the script for sending emails looks like:

 $to_email = "[email protected]"; $subject = "Simple Email Testing via PHP"; $body = "Hello,nn It is a testing email sent by PHP Script"; $headers = "From: sender\'s email"; if (mail($to_email, $subject, $body, $headers)) < echo "Email successfully sent to $to_email. "; > else < echo "Email sending failed. "; > ?>

After following the steps above, you will manage to send an email. However, if you still face problems in sending an email, then the reason can be among the following:

  1. A broken port.
  2. A wrong password.
  3. The emails are sent late.
  4. Gmail doesn’t obtain the necessary permissions.
  5. Wrong email configuration.

What is XAMPP?

XAMPP is considered a free and open-source cross-platform web server solution stack package. It is designed and developed by Apache Friends. It consists of the MariaDB database, Apache HTTP Server, as well as interpreters for scripts written in the PHP and Perl programming languages.

Источник

How to configure xampp to send email

I know this is elsewhere on the site but for some reason the answers I’ve found on here still haven’t helped I still can’t get it to work after trying different things all day. My goal was to have a confirmation code sent to the email that the user enters. I only know a small amount of PHP and followed a tutorial for the login/registration system but I’m fairly sure the php is working fine and the problem lies in my sendmail.ini and php.ini. Here is my sendmail.ini

; 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 ; SMTPS (SSL) support ; auto = use SSL for port 465, otherwise try to use TLS ; ssl = alway use SSL ; tls = always use TLS ; none = never try to use SSL smtp_ssl=auto ; 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=mydomain.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= myemail@gmail.com auth_password= mygmailpass ; if your smtp server uses pop3 before smtp authentication, modify the ; following three lines. do not enable unless it is required. pop3_server= pop3_username= pop3_password= ; force the sender to always be the following email address ; this will only affect the "MAIL FROM" command, it won't modify ; the "From: " header of the message content force_sender=myemail@gmail.com ; force the sender to always be the following email address ; this will only affect the "RCTP TO" command, it won't modify ; the "To: " header of the message content force_recipient= ; 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= 
extension=php_openssl.dll [mail function] ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury SMTP =smtp.gmail.com smtp_port =587 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = myemail@gmail.com sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" ;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" ; 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 = 
 //whether the email is blank if($_POST['email'] == '') < $_SESSION['error']['email'] = "E-mail is required."; >else < //whether the email format is correct if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $_POST['email'])) < //if it has the correct format whether the email has already exist $email= $_POST['email']; $sql1 = "SELECT * FROM user WHERE email = '$email'"; $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error()); if (mysqli_num_rows($result1) >0) < $_SESSION['error']['email'] = "This Email is already used."; >> else < //this error will set if the email format is not correct $_SESSION['error']['email'] = "Your email is not valid."; >> //whether the password is blank if($_POST['password'] == '') < $_SESSION['error']['password'] = "Password is required."; >//if the error exist, we will go to registration form if(isset($_SESSION['error'])) < header("Location: index.php"); exit; >else < $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; $com_code = md5(uniqid(rand())); $sql2 = "INSERT INTO user (username, email, password, com_code) VALUES ('$username', '$email', '$password', '$com_code')"; $result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error()); if($result2) < $to = $email; $subject = "Confirmation for $username"; $header = "Confirmation from"; $message = "Please click the link below to verify and activate your account. rn"; $message .= "http://www.yourname.com/confirm.php?passkey=$com_code"; $sentmail = mail($to,$subject,$message,$header); if($sentmail) < echo "Your confirmation link has been sent to your e-mail address."; >else < echo "Error while sending confirmation link to your e-mail address"; >> > > ?> 

Like I said I’ve been working on this for a while and I can’t seem to figure it out, I assume it’s something really simple but since I’m still learning I didn’t see it. Thanks for all the help!

Источник

(WAMP/XAMP) send Mail using SMTP localhost [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

How to send mail from localhost SMTP (using Wamp,Xampp or etc..)? PHP mail() doesn’t seem to work natively. Can anybody give the instructions?

With xampp or wampp you need to configure mercury for sending mails from localhost. Are you asking for the configuration?

6 Answers 6

Method 1 (Preferred) — Using hMailServer

After installation, you need the following configuration to properly send mail from wampserver:

1) When you first open hMailServer Administrator, you need to add a new domain. 2) Click on the "Add Domain . " button at the Welcome page. 3) Under the domain text field, enter your computer's IP, in this case it should be 127.0.0.1. 4) Click on the Save button. 5) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab 6) Enter "localhost" in the localhost name field. 7) Click on the Save button. 

If you need to send mail using a FROM addressee of another computer, you need to allow deliveries from External to External accounts. To do that, follow these steps:

1) Go to Settings>Advanced>IP Ranges and double click on "My Computer" which should have IP address of 127.0.0.1 2) Check the Allow Deliveries from External to External accounts checkbox. 3) Save settings using Save button. 

(However, Windows Live/Hotmail has denied all emails coming from dynamic IPs, which most residential computers are using. The workaround is to use Gmail account )

Note to use Gmail users :

1) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab 2) Enter "smtp.gmail.com" in the Remote Host name field. 3) Enter "465" as the port number 4) Check "Server requires authentication" 5) Enter gmail address in the Username 6) Enter gmail password in the password 7) Check "Use SSL" 

(Note, From field doesnt function with gmail)
*p.s. For some people it might also be needed to untick everything under require SMTP authentication in :

  • for local : Settings>Advanced>IP Ranges>»My Computer»
  • for external : Settings>Advanced>IP Ranges>»Internet»

Method 2 — Using SendMail

Method 3 — Using different methods

Источник

Send Mail From Localhost in PHP Using XAMPP

Send Mail From Localhost in PHP Using XAMPP, Firstly, PHP is an open-source scripting language, which means where you can change your.

Send Mail From Localhost in PHP Using XAMPP, Firstly, PHP is an open-source scripting language, which means where you can change your PHP core files according to your requirements.

PHP also has a SENDMAIL inbuilt package, which is used to send mail from a localhost server like XAMPP.

Send Mail From Localhost in PHP Using XAMPP

The below process explained from the XAMPP server.

4+ Steps to Send Mail From Localhost in PHP Using XAMPP

Here are list of all the steps which I explained below completely.

  • Create an APP password to setup Gmail SMTP.
  • Modify [mail function] on the PHP config file (php.ini) .
  • Modify [mail function] on the SendMail config file (sendmail.ini) .
  • Restart Apache server.
  • Try the example source code.

Create an APP password to setup Gmail SMTP

To access Gmail account which is protected by 2Step Authentication we have to create APP password which helps to send mail using our Gmail account as SMTP account.

Create APP password on Gmail

  • Go to https://security.google.com/settings/security/apppasswords
  • Select Mail and the Other like below image,

Then you get the password like “woaablyvvycyznenv” this. Keep it safe for further.

Modify [mail function] on the PHP config file (php.ini)

  • Go to this location: C:\XAMPP\php\php.ini
  • Open php.ini file on any text editor and search [mail function]

Changes on [mail function] on php.ini file

Remove semicolon (;) first on below lines, and put the given changes,

SMTP=smtp.gmail.com
smtp_port=465
sendmail_from = yourGmailID@gmail.com
sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”

Modify [mail function] on the SendMail config file (sendmail.ini)

  • Now next is the Open Sendmail configuration file named sendmail.ini.
  • path:c:\xampp\sendmail\sendmail.ini

search [mail function]

Changes on [mail function] on sendmail.ini file

  • smtp_server=smtp.gmail.com
  • smtp_port=465
  • smtp_ssl=auto
  • error_logfile=error.log
  • debug_logfile=debug.log
  • auth_username=writeyourgmail@gmail.com
  • auth_password=PUTthecreatedAppPasswordOnFirstStep

Restart the APACHE Server on XAMPP control panel.

Источник

Оцените статью