tags:

views:

42

answers:

3

Hi,

i wanna write a script sending e-mail to my client automatically using php

How do i send it automatically, for example, if they enter their email. and click submit

i wanna send this e-mail automatically

And, second do i need smtp server on my host? can i just this in any free hosting?

Thanks you guys and im so sorry for my language

Nikky

A: 

As simple as it can get...

<?php
$email = @$_REQUEST['email'];
if ( !empty( $email ) )
{
  mail( $email, 'subject', 'message' );
}
?>
Rudisimo
+1  A: 

I probably wouldn't go with using the mail function directly : to many things you have to care about...

Instead, I would recommend using some mail-related library, which will deal with a lot of things for you.

One of those (which seems to have some success nowadays -- it's being integrated in the Symfony framework, for instance) is Swift Mailer.

Of course, it might be a bit overkill for just a simple mail... But investing some time in learning how to use such a library is always worth it ;-)

Pascal MARTIN
Composing and delivering valid emails is harder than it looks at first glance. Granted, maybe it's not rocket science. But in almost all cases it's something of the category "already solved, no need to fail at the first five/six/seven attempts reinventing the wheel". And Swiftmailer really is a nifty library.
VolkerK