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?
Help with Hyperlink
Hi,What I am trying to do may be simple, I just can't get it to work. Ok...I am using Zend and so the database connect that I need for this is a simple call to it like Code:
MS are the best!!!
Visit http://www.microsoft.com/australia/windows/default.aspx?h=watch-a-demo and click the massive 'Watch a demo' banner.This, on the day the OS was released. They can't even get a website functioning
Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is working perfectly in IE (I have version 8 on this computer) But it wont work on Firefox. I'm not
Access website from only 1 computer...?
One of my customers wants his website to only be accessed by people in which they bought the website membership from on their computer. He's afraid that the users might share their login's with their
PHP5 - AJAX help
I've been following the tutorial on w2schools (http://www.w3schools.com/php/php_ajax_database.asp) about using AJAX and a database. It's my first time actually using AJAX and I've run into a problem.
i have no idea why this isn't working
Code: <?phpsession_start();include("connect.php");error_reporting(E_ALL);ini_set('display_errors', '1'); $username = "Master";$password = "pword";$host =
Problem with Subscreen
Dear Experts ,
query help
Hi experts.
PHP Directory Listing Not working
Hey Guys,I need help, I tried a ton of directory listing scripts and they all don't work. Althogh the normal Apache Directory Indexing does work when you visit. The URL is
newbie error
what is wrong with this code ? <html><body><?php$conn=odbc_connect('Towel','','');if (!$conn) {exit("Connection Failed: " . $conn);}$sql="SELECT *