SMTP
If we want that our pages PHP send electronic mails, using the function
mail() for systems of recommendations, contact or other applications of send mail, we can install a smtp server. With these servers we will be able to send post office from PHP, but we will not be able to receive since they are SMTP server (Send) and not Pop/imap (incoming).
Configuration of the file php.ini
We are going to open with our text editor the file php.ini located in C:\php \,(or other location C:\windows if it is already instaled) this one comes by defect formed for a server mail installed in localhost, but
sendmail_from can be changed to him to the variable, that is in charge to put the sender who will appear to him to the person who receives the mail if we did not specify it in the heads, in field FROM, of the function mail() of our pages PHP.
We looked for the lines:
[mail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = me@localhost.com
We can change
sendmail_from placing the sender that you want, for example:
user@myadress.com
Of such form that is:
[mail function]
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = user@myadress.com
We closed, and kept the changes and we copied the file, php.ini, to C:\WINDOWS\
Installation of a smtp mail server
A good smtp server would be
QK smtp Server we found it in
http://www.qksoft.com /, click in
Download now and to begin the installation. It is not necessary to modify nothing in this program, it is only necessary to have it open and the Apache running and we can send post office by means of PHP.
Testing smtp server
We opened the Notepad and we wrote:
<?php
$sfrom="sender@mail.com"; //Sender
$sdestination="destination@mail.com"; //Destination
$ssubject="Test SMTP"; //Subject
$shtml="smtp works correctly."; //Mensaje
$sheader="From:".$sfrom."\nReply-To:".$sfrom."\n";
$sheader=$sheader."X-Mailer:PHP/".phpversion()."\n";
$sheader=$sheader."Mime-Version: 1.0\n";
$sheader=$sheader."Content-Type: text/html";
mail($sdestination,$ssubject,$shtml,$sheader);
?>
You change
sender@mail.com that will be the one that appears like sender of the mail and
destination@mail.com that will be the mail mailbox where east Test smtp arrived.
We save the file as TestSMTP.php and place in your root folder (htdocs or www)
With start apache and
QK smtp Server .
In the bar of directions of the navigator you write:
http://localhost/TestSMTP.php or
http://127.0.0.1/TestSMTP.php nothing else to enter this page executes script and send the mail. Later go to the mailbox which you put in #$$sdestination>, to see if arrived the mail successfully. If you reload the page the mail is sent again.
"as you can see my English is very poor
, but You must understand something"