Monday, February 14, 2011

Sending emails from the localhost in php

Following article describes how to send an email from local host using XAMPP , WAMP or any other PHP servers. You have to do the following configurations in php.ini file in your local server.

1.Search for the attribute called "SMTP" in the php.ini file. Generally you can find the line "SMTP="localhost"". Change the localhost to smtp server name of your ISP and there is another attribute called "smtp_port" which should be set to 25.

2.) Specify the following headers and try to send the mail.

$headers = ‘MIME-Version: 1.0′ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”;
$headers .= ‘From: sender@sender.com’ . “\r\n”;
mail(“you@yourdomain.com”,”test subject”,”test body”,$headers);

Well that’s all, the mail is sent to “you@yourdomain.com” from the localhost.

1 comment:

David Jones said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP 7 Training in chennai | PHP 7 Training Course

PHP 7 Training in chennai | Online PHP 7 Course