How to send Email using PHP with MySQL in Linux Server?..

Answers were Sorted based on User's Feedback



How to send Email using PHP with MySQL in Linux Server?....

Answer / karthi

PHP Code
The PHP code to send email is simply one PHP function mail
() . The basic format for this function is:
mail("to", "subject", "message");

For example (this is straight out of the online help that
comes with PHP):
mail("joecool@example.com", "My Subject", "Line 1\nLine 2
\nLine 3");
PHP does need to be installed and setup properly for mail
to work. On a Unix-type setup, such as Linux, PHP will use
your local sendmail program to send it. Windows machines
use SMTP. If you need to you can edit your php.ini file and
set the appropiate SMTP host you use to send email.
Here's the code to send the email:
if ($REQUEST_METHOD == "POST") {
// Just to be on the safe side - I'll strip out HTML tags
// (scripting code may mess with some email clients)
$realname = strip_tags($realname);
$email = strip_tags($email);
$feedback = strip_tags($feedback);
// setup variables
$sendto = "$email";
$subject = "Send Mail Feedback Using PHP";
$message = "$realname, $email\n\n$feedback";
// send email
mail($sendto, $subject, $message);
}
?>

Is This Answer Correct ?    6 Yes 2 No

How to send Email using PHP with MySQL in Linux Server?....

Answer / ks.tarun

u can send mail via php in linux with he help of linux
commands s well like..
<?php

$file = "test.txt";
system("echo -e 'Message Body' | mutt -s 'Subject' -a
test.txt email@email.com");
?>

that will send mail to the recipient with attachment of file.
for that u just have to install mutt rpm also
for that run below commands:

# yum -y install *mutt*

Is This Answer Correct ?    3 Yes 1 No

How to send Email using PHP with MySQL in Linux Server?....

Answer / amit srivastava

<?php
include("Mail.php");
/* mail setup recipients, subject etc */
$recipients = "feedback@yourdot.com";
$headers["From"] = "user@somewhere.com";
$headers["To"] = "feedback@yourdot.com";
$headers["Subject"] = "User feedback";
$mailmsg = "Hello, This is a test.";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "smtp.mycorp.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "smtpusername";
$smtpinfo["password"] = "smtpPassword";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More PHP Interview Questions

what is constructor in a class, how it is work, how it is call?

2 Answers  


What are sql functions?

0 Answers  


What is the function of mysql_real_escape_string in php?

0 Answers  


What types of loops exist in php?

0 Answers  


<?php /** * @version 1.0 $ * @package HelloWorld * @copyright (C) 2005 Andrew Eddie * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ /** ensure this file is being included by a parent file */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); ?> <?php $database =& JFactory::getDBO(); //$sql = 'SELECT name, username FROM #__users'; $sql="select a.id, a.title, a.introtext, a.created_by, a.created from jos_content a, jos_content_frontpage b where a.id=b.content_id and b.ordering='2'"; $database->setQuery( $sql ); $user = NULL; $user = $database->loadObject(); //echo 'Name: ' . $user->name . '<br />'; echo '<h1>' . $user->title . '</h1><br />'; //echo 'Username: ' . $user->username; echo ' ' . $user->introtext; i write this and fetch the result from the database the result is The Intranet is up and working ! Our intranet is up and working and should be accessible from both Mumbai and NOIDA. As you will notice, this template, look & feel is not in line with our corporate indentity but we chose the route of "form-follows-funtion" In the first phase, we are rolling out functionality that is critical to all of us - Policies and How-to documents. In subsequent phases, we will be launching other features. Keep watching this space for more details i want to see only 4 line of top then how this may done

0 Answers   Infovision,






How do I check environment variables?

0 Answers  


Tell me how to strip whitespace (or other characters) from the beginning and end of a string?

0 Answers  


What is php session_start() and session_destroy() function?

0 Answers  


PHP can be used frontend of for backend?

3 Answers   Global Logic,


How arrays are passed through arguments?

0 Answers  


How to create a public static method in PHP?

0 Answers  


Where is the submitted form data stored?

0 Answers  


Categories