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>

156 Like 39 Dislike
Previous php-forum Next php-forum
Other php-forum

php global variable
how can we create global variable so we can use its value in any form.. Please give example to

Polymorphism
Was wondering if someone could explain this a little better to me. I had always assumed that it had

Changes to hosting company's server has affected web contact form
I started a thread a couple of months ago about the contact forms on my client's website. Basically

start new row of pictures
on my site www.budstreasureauctions.com there is a featured auctions box that users will pay to get

Filtering Tables
Hello Thanks for any help any one can give Im very new to PHP..

I need to pull data for clien

Undefined index: username HELP NEWBIE
I am trying a simple login/logout for my website. It works well with checking if the username exists

frame help
on the bottom frame is menu.html

Code: <body><form action='link.php' met

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

Tracking Unique Clicks
Hi guys and gals,

Basically I have a database which tracks clicks on my outbound links, I do

Multiple forms on the same page (safari)
Hello everyone,

I have 3 forms on the same page, that opens in a new window and submits to a

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash