-1

I am new to Php and I want to know how mailto script works in php? Can anyone please provide a script for that?

Taryn
  • 242,637
  • 56
  • 362
  • 405
sharath
  • 1
  • 1

6 Answers6

6

It's actually very simple: Just use php's "mail" function. See:
http://php.net/manual/en/function.mail.php

It's as easy as typing

mail($to, $subject, $message, "From: some@address.com");

This returns a boolean so you can check to see if it was sent successfully (it will be, unless your server's mail system is misconfigured) by doing something like:

$success = mail([...]);
if ($success)
    echo "your message was sent successfully";
else
    echo "your message did not send for some reason :(";

or even just

if (mail([...]))
    echo "success";
else
    echo "failure";
Mala
  • 14,178
  • 25
  • 88
  • 119
4

PHP's built-in mail command is useful and works for most cases - simple & sparse. If you need more features, trying use a mail script like PHPMailer.

leepowers
  • 37,828
  • 23
  • 98
  • 129
3

See mail function in PHP.

rahul
  • 184,426
  • 49
  • 232
  • 263
2

Article

Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138
2

Of course the easiest way to do it is using PHP's mail() command but it is not particularly efficient. The PEAR Mail Package is a good option or you can use a PHP class. (You can find loads on PHP Classes.)

Chaim
  • 2,109
  • 4
  • 27
  • 48
1

To save a lot of heartache, use something like SwiftMailer.

Blair McMillan
  • 5,299
  • 2
  • 25
  • 45