PDA

View Full Version : PHP Mail help!


Aboobie
10-02-2010, 20:53
Ok I need some help!!

I've been doing a web site for a local charity and they want a form that when submitted sends an email.
I've quite happily added a form to the html with client side javascript validation but I'm having trouble with the mail part.

I've decided to use a PHP script to do the work but I'm having trouble getting it all working on their web server. It should be noted I've never worked with PHP before.

Here's what I've written:

<?php

include('Mail.php');
$mail = Mail::factory("mail");


$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$number = $_REQUEST['number'] ;
$course = $_REQUEST['course'] ;
$info = $_REQUEST['info'] ;

$from = "Mr Testie <smcshaw@hotmail.com>";
$to = "Steven Shaw <smcshaw@hotmail.com>";
$subject = "Workshop Enquiry from " + $name;

$body = "Workshop enquiry from: " + $name + "\nEmail: " + $email + "\nTelephone number: " + $number + "\nFor course: " + $course + ".\nAdditional Info: " + $info;

$host = "authsmtp.streamline.net";
$username = "info@themusikeracademy.com";
$password = "*******";

$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);

?>

Is this even vaguely right?


They're with streamline and I've got the added problem of inadvertantly taking their web site down as I changed the web server to linux tonight thinking this might have been my problem.

My questions are where do I need to put this on the web server, what do I need change on the server to get it all working? Basically, HELP!

leowyatt
10-02-2010, 20:57
we send mail through exim on our servers not sure what you are using

Aboobie
10-02-2010, 21:08
There's no mention of exim only scripting in PHP, ASP...

leowyatt
10-02-2010, 21:12
what do they use on the server to send email?

Aboobie
10-02-2010, 21:15
what do they use on the server to send email?

I've just got the smtp server details. Everything has to be done with a custom script.

leowyatt
10-02-2010, 21:22
try this

http://articles.techrepublic.com.com/5100-10878_11-1045471.html

Aboobie
11-02-2010, 12:19
All sorted.

I found out they use JMail so I rewrote it all as an asp. Easy and it all works nice.