4 Replies - 2792 Views - Last Post: 26 August 2011 - 01:39 PM Rate Topic: -----

#1 shabbaranks   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 08-August 11

Creating a php contact form and mailing via exchange

Posted 26 August 2011 - 07:39 AM

Hi all... Ive created a contact form based on the tutorial on this site as per below:

<?php
// Step 1
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];

$to = "[email protected]"; // The e-mail address you want the message sent to

// Step 2
$header = "From: " . $name . " < " . $email . ">“;

// Step 3
mail($to, $subject, $message, $header);

// Step 4
header(”Location: ./index.php”);

?>


The location of the site is on an ubuntu server - do I need to allow that server for smtp relay from our exchange server?

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a php contact form and mailing via exchange

#2 aaron1178   User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 170
  • View blog
  • Posts: 1,311
  • Joined: 22-October 08

Re: Creating a php contact form and mailing via exchange

Posted 26 August 2011 - 07:42 AM

Depends... If the server is a local server, then you will need a mail server or an out-side mail server. I use my reseller account mail server for local and web :)

EDIT:

Just to point out an error

header(”Location: ./index.php”);



to

header(”Location: ../index.php”);


This post has been edited by aaron1178: 26 August 2011 - 07:45 AM

Was This Post Helpful? 1
  • +
  • -

#3 shabbaranks   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 08-August 11

Re: Creating a php contact form and mailing via exchange

Posted 26 August 2011 - 07:58 AM

Sorry I should have made my question a little clearer, the mail server and the web server are all on the same subnet\network. So from your reply I would say I need to allow smtp relay for the web server?

Thanks again :)
Was This Post Helpful? 0
  • +
  • -

#4 shabbaranks   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 08-August 11

Re: Creating a php contact form and mailing via exchange

Posted 26 August 2011 - 08:43 AM

Ive since found the answer. I would need to edit the php.ini file and enter the details of our smtp server then mail will flow.

:)
Was This Post Helpful? 1
  • +
  • -

#5 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: Creating a php contact form and mailing via exchange

Posted 26 August 2011 - 01:39 PM

View Postshabbaranks, on 26 August 2011 - 04:43 PM, said:

Ive since found the answer. I would need to edit the php.ini file and enter the details of our smtp server then mail will flow.

This is one solution, however without the smtp details PHP would (by default) use the sendmail binary on the server if it exists.

If you didn't want to screw about with opening up SMTP Relay (which is generally bad if you do it on a global scale, but I'm sure you didn't!) then you can simply add the server's IP address to the list of allowed senders in the SPF record, and it will be almost asif it came from the SMTP server.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1