Showing posts with label SMTP. Show all posts
Showing posts with label SMTP. Show all posts

Friday, 26 April 2013

How to set up sendmail on your Ubuntu LAMP localhost

This is beautifully simple:
Step 1. Open up a terminal and type

sudo apt-get install sendmail
This will install the complete sendmail application. It will take a minute or so to complete.
Step 2.  Open up a terminal and type
This will display your hostname.
Step 3.  Open up a terminal and type
sudo gedit /etc/hosts
or whatever text editor you like using to open up your hosts file for editing.
Step 4. Modify the first line so it reads    localhost localhost.localdomain yourhostname
Restart your computer.
It will now work.

Friday, 24 September 2010

SMTP from XAMPP on a localhost using your Google mail Account

This may seem a little obscure but believe me, this blog could save you a lot of time.

Imagine you have XAMPP installed on your Windows computer as localhost. You are writing an application which requires e-mails to be sent and you need to test your code. You have a Google e-mail account and you'd like to use the SMTP service which comes with that.

Let's start by creating our little PHP script which we are going to use for testing.

    mail('','test subject','test body');
There. That wasn't too difficult was it.

Next we need to edit our php.ini file. The php.ini file will be in something like C:\XAMPP\php. We are looking for the [mail function] variables. For which we need entries like this:

[mail function]
sendmail_path = "C:/xampp/sendmail/sendmail.exe -t"

Couple things to note from above. The smtp_port and look carefully at the slashes of the sendmail_path.

Now we are on to our final step. We need to edit sendmail.php which would be under something like C:\XAMPP\sendmail. You need to replace the contents of the file with something like this:


You must now restart your Apache service in order for it to work.

Now to test your script. Open up your web browser and load it like this http://localhost/myscript.php
Check your Google mail account to see if it's arrived.

Good luck!