LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-16-2010, 04:52 AM   #1
ashishkhandelwal
Member
 
Registered: Jan 2010
Posts: 34

Rep: Reputation: 15
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.
 
Old 04-16-2010, 05:09 AM   #2
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Bangalore, India
Distribution: Linux Mint 13
Posts: 590

Rep: Reputation: 64
Quote:
Originally Posted by ashishkhandelwal View Post
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;
}
}
 
Old 04-16-2010, 05:56 AM   #3
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
RTFM
http://php.net/manual/en/function.mail.php
 
Old 04-16-2010, 09:20 AM   #4
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,205

Rep: Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472
Quote:
Originally Posted by ashishkhandelwal View Post
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.
 
  


Reply

Tags
mail, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to send email... bfloeagle Linux - General 5 10-13-2009 10:20 AM
php script don't send email with qmail pk_kala Linux - Server 8 05-02-2009 08:33 AM
send email from a script r.stiltskin Ubuntu 7 07-26-2008 12:36 AM
How to send an email within a script??? johnsanty Programming 19 09-02-2006 12:43 PM
I need to send email from PHP - How can I do this easily? wadesmart Ubuntu 6 07-06-2006 03:15 AM


All times are GMT -5. The time now is 12:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration