First off I apologize if this is a newbie question, and I generally don't like asking questions that have already been asked 1,000,000 times, but I've searched far and wide and cannot find a solution to my problem.
Basically I run an experimental server on my home network. I use LAMP (Ubuntu Server, Apache2.2, MySQL5, PHP5).
I simply want to take the data from an HTML form and submit it as an e-mail. I tried using the mail() function like this:
Code: $email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$sentmail = mail("example@gmail.com",$subject,$message,"FROM: ".$email."rn");
if($sentmail) {
echo 'Your message has been sent!';
} else {
echo 'Cannot send message.';
}
After some googling, I found one solution that said to add this line:
Code: ini_set("sendmail_from", "example@gmail.com");but it made no difference.
I finally decided to try a different approach using SMTP:
Code: require_once "Mail.php";
$from = "Form Data <".$_POST['email'].">";
$to = "My Name <example@gmail.com>";
$subject = $_POST['subject'];
$body = $_POST['message'];
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "foo@gmail.com";
$password = "bar";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
Still not working!
This is quite frustrating. It always returns a value of "true" but never actually sends the messages!
Maybe it would help if I had a better understanding of what the mail() function actually does. Where does the message go when handled by mail()? Mustn't it go through a mail server at some point? Port 25 is iffy on my setup, so that could be the issue with mail().
When using the PEAR method though, I specifically indicate port 465, so that can't be the issue.
What am I missing here?
Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called datetime. I tried to use Now() but its not working. Code: <?php$con =
Placing and array within an array then sorting it!
I have a page that runs two large mysql queries and saves the results into arrays, in php I then perform a simple multiplication between the two arrays and the results is displayed in a dynamic html
New Search Engine
Hey everyone,I have a ZIP Code Radius search engine already functional. it displays all of the ZIP codes within a specified mileage around a central ZIP code.I have an auction site that the client
Grabbing Values From an Array for Posting
I have a grid array that I am using with a form that when it hits the currently named test.php it logs in and grabs 3 coordinates (i.e. B1, D3, etc). which come back as XML fields
How do I get the row number from from an sql table query
Hi allI have a table that I query and it returns a number of rows.mysql_num_rows($query) = $totalI want to have next and previous buttons, is there a way of retrieving the current row number, and can
IIS & NW MII on the same server
Hi,
Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on how long ago that was in the past if 24 hours has not passed.if ($reQuest!=""){ if
How can you detect variable string in a massive string?
Ok guys, i need some help with this one.I am going to be getting a large string, like 10-20 paragraphs. I will also have an array or words that i would like to search it for.
Material Issuing for receiving batch
Dear All experts in MM/ PP,
OOP help
okay so i have a class im making it has everything setup i just need to randomize the 2 variables and return which variable that was randomized and output it.Code: <?phpclass hit_chance {