Please help with SMTP Authenticated PHP Email Form
Posted on
16th Feb 2014 07:03 pm by
admin
Hello, I'm creating a PHP email form, and for this particular server, I have to use SMTP Authentication. They hosting service sent me this link: http://email.about.com/od/emailprogramm ... cation.htm
Anyway, I have the form created, and I created the PHP file called mail.php. I finally got it to where it does send me an email, but the message is completely blank. My form has four fields, which are: name, email, telephone, and message, so these should each be emailed to me when the form is filled out.
Thank you in advance if anyone can look this over.
Here is my PHP code:
Code: [Select]
<?php
require_once "Mail.php";
$from = "Jane Doe <jane.doe@gmail.com>";
$to = "JD <jim.doe@gmail.com>";
$subject = "Request to contact me";
$name = "name:n";
$email = "email:n";
$phone = "phone:n";
$message = "message:n";
$host = "smtp.gmail.com";
$username = "jane.doe";
$password = "blackcat35";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
print "<meta http-equiv="refresh" content="0;URL=received.htm">";
}
?>
And here is my HTML form:
Code: [Select]
<form method="POST" action="mail.php">
<p>Fields marked (*) are required</p>
<p><strong>Name:* </strong>
<input name="name" type="text" size="40" maxlength="50" id="name" />
<p><strong>Email:* </strong>
<input name="email" type="text" size="40" id="email">
<p><strong>Telephone:</strong>
<input name="message" type="text" size="40" maxlength="30" id="message" />
<p><strong>Message:* </strong>
<textarea name="message" cols="40" id="message"></textarea>
<p><input type="submit" name="submit" value="Submit">
<input type="reset" name="Clear" id="Clear" value="Reset" />
</form>
No comments posted yet
Your Answer:
Login to answer
156
39
Other forums
drop-down with sub-category appear
Hello,
i know how to build a simple dro-down list, im looking for a code when im gonna choose
This is driving me nuts!
This insert query looks to be alright, however I get this error:
QuoteYou have an error in yo
multiple recipients + dbuser mail recall
Hello,
I am building a php login script.
When the user registers the script will send
Can we convert non uni code system into unicode
Hi All,
Presently i am using non-unicode system and the sap version is 4.7.
Can i c
server trace logs
could any one tell me from where do i get error logs in xMII??I want to check the reason for dtabase
Pro-rata Billing in Periodic Billing for Rental
Hi guys,
We have a situation, where a rental contract starts at the mid of the month say
What is SAP Avatar ?
Hi All,
This G.Satish , my boss asked me to explore on SAP Avatar. I searced in internet
Socket Server Response Headers
Earlier I had a post about my Socket Server, I wasn't able to get it to connect, now I can
I
Staff Induction System - No idea where to go from here!!!
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi
how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s