mailer form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
snefmoo
Forum Newbie
Posts: 1
Joined: Thu Apr 16, 2009 9:34 am

mailer form

Post by snefmoo »

im designing a website for uni and we are using server2go so that we can view the php script. i have a form that lets a user select an email address from a drop down, but when i send the message i get this error message,

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Users\Steffi\Desktop\dissertation second site\server\distribute_apache2.0\htdocs\sendmail.php on line 15

my php code for this is

Code: Select all

<?php
if (isset($_POST['send']))
 
  {
  
$to = $_POST['emailler'];
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$subject = "Website Question";
 
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
 
echo "Data has been submitted to $to!";
mail ($to, $body, $subject);
 
} else {
 
echo "your email has not been sent please try again!";
 
}
?>
looking at the config files i found this

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

how would i set this within the form?
silverspy18
Forum Newbie
Posts: 23
Joined: Sun Apr 05, 2009 5:55 pm

Re: mailer form

Post by silverspy18 »

I think you can use the ini_set() function for this.

You should be able to do something like this:

Code: Select all

 
ini_set  ("SMTP", server address);
ini_set  ("sendmail_from", email address you are sending from);
 
Post Reply