LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PHP script to send email in linux (http://www.linuxquestions.org/questions/linux-newbie-8/php-script-to-send-email-in-linux-802359/)

ashishkhandelwal 04-16-2010 05:52 AM

PHP script to send email in linux
 
Hello,

I want a php example script to send email in linux.I know that it could be done using mail() function but i dont know how to use it so if anybody can send me a working script then i will be very grateful to him.

Thank you.

Sayan Acharjee 04-16-2010 06:09 AM

Quote:

Originally Posted by ashishkhandelwal (Post 3937376)
Hello,

I want a php example script to send email in linux.I know that it could be done using mail() function but i dont know how to use it so if anybody can send me a working script then i will be very grateful to him.

Thank you.

Here is a working script, see if this script helps you:
Quote:

<?php
session_start();

if( isset($_POST['submit']))
{
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) )
{
$to = 'abc@abc.com';
$subject = 'Mail From -'.$_POST["name"];
$message=$_POST["message"];
$message=wordwrap($message,50);
//$headers=$_POST["email"];

$headers = 'From: '.$_POST["email"];




mail($to, $subject, $message, $headers);

header("Location: ".$_POST['action_url'].'?id=1');

exit;
unset($_SESSION['security_code']);
}
else
{

header("Location: ".$_POST['action_url'].'?id=0');

exit;
}
}

PMP 04-16-2010 06:56 AM

RTFM
http://php.net/manual/en/function.mail.php

TB0ne 04-16-2010 10:20 AM

Quote:

Originally Posted by ashishkhandelwal (Post 3937376)
Hello,

I want a php example script to send email in linux.I know that it could be done using mail() function but i dont know how to use it so if anybody can send me a working script then i will be very grateful to him.

Thank you.

There are lots out on Google, but coming here and asking someone else to write your code for you is fairly lazy.

Put some effort into learning and doing for yourself, don't just go and ask for handouts.


All times are GMT -5. The time now is 08:27 PM.