Send Email In Php From Localhost

How To Send Email In Php From Localhost? [Simple Guide]

The Localhost is used as a development server for testing purposes. Whenever you need to test the functionalities of a web application, you can use the Localhost. You can send an email from Localhost with the Sendmail package, which is available in XAMPP. So if you are using XAMPP, you can easily send emails from Localhost. The PHP Mailer library provides the easiest way to send an email message from Localhost with an SMTP server using PHP. You can send text messages and HTML emails from Localhost in PHP using the PHPMailer. You can use any client such as a Gmail account to send emails from Localhost as an SMTP server. In the below section, let us see in detail about how to send email in PHP from Localhost.

Configuring Your Google Account:

  • Step 1: Turn on your computer and establish a reliable internet connection.
  • Step 2: Go to your default browser and log in to your Google account. In the left side of the window, you will be able to see the security page. Click on it.
  • Step 3: Scroll down to the Less secure app access section. Turn on Less secure app access. Now you can easily use your Gmail account as an SMTP server.

Configuration Changes In Php Mail:

  • Step 1: Enter the SMTP Host server name like smtp.gmail.com.
  • Step 2: Enter the port number (Example: 465).
  • Step 3: Enter your SMTP username along with the password.

Steps To Be Followed:

  • Step 1: You need to enable the php_openssl php extension from the php.ini file.
  • Step 2: If you are using the XAMPP, the file is located in c:\XAMPP\php\php.ini.
  • Step 3: You can also download the file from php_openssl.dll.
  • Step 4: Now you need to find the mail function in the php.ini file.
  • Step 5: Open Sendmail.ini, which is located on c:\xampp\sendmail\sendmail.ini and you need to change the SMTP configuration.
  • Step 6: Now it's time to restart your Apache server.
  • Step 7: In the next step, you need to send a mail using the php mail() function.
  • Step 8: If port 25 is not opening, you can change the port number to 587 or 465 and try again.
  • Step 9: By following the above-stated steps, you would have configured and send Email In Php From Localhost, and you can use it to the fullest.

Related Searches

How To Encrypt Email?

How To Encrypt Email?

In order to prevent third parties from reading your mail content, email encryption is done, which is basically digitizing the information within. 

How To Stop Spam Emails?

How To Stop Spam Emails?

There are not many ways to prevent spam from piling up in your Inbox. Here’s how you can filter out most of them.

Fix AT&T Email Error

Fix AT&T Email Error 0x800CCC0F

AT&T Email error 0x800CCC0F occurs when mails are not being sent or received through AT&T services. Due to the technical glitches causing it, many email functions are disabled. The computer’s Operating System might get frozen.

How To Delete All Emails In Gmail?

How To Delete All Emails In Gmail?

Open the Gmail app.Select the inbox tab you want to delete.You’ll find the Empty Box button over the Compose button.