Page 1 of 1

SMTP and headers

Posted: Sat Jul 23, 2005 12:13 pm
by tomE
I simply don't understand what this means can anyone explain? I am trying to test an email script locally with the form submitting to a yahoo email address. does anyone know how to rectify this?

There also appears to be a problem with the header, although its nothing i can see.

here is the code

Code: Select all

<?
$name=$_REQUESTї'name'];
$email=$_REQUESTї'email'];
$comments=$_REQUESTї'comments'];
$to=&quote;me@yahoo.co.uk&quote;;
$message=&quote;$name just filled in your comments form. They said:\n$comments\n\nTheir e-mail address was: $email&quote;;
(mail($to,&quote;Practice Feedback form &quote;,$message,&quote;From: $email\n&quote;));
header ( &quote;Location: http://localhost/contact_redirect.html&quote; );
?>
Here is the error warning

Code: Select all

Warning: mail(): Failed to connect to mailserver at &quote;localhost&quote; port 25, verify your &quote;SMTP&quote; and &quote;smtp_port&quote; setting in php.ini or use ini_set() in c:\inetpub\wwwroot\PHP\mail.php on line 12

Warning: Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\PHP\mail.php:12) in c:\inetpub\wwwroot\PHP\mail.php on line 13

Posted: Sat Jul 23, 2005 12:16 pm
by Chris Corbyn
I'm assuming you know what an SMTP server is and that you at least think you have one running on the PC?

If not, find out what your SMTP server is from your ISP and then set it in php.ini under the SMTP directive ;)

It can't find a running SMTP server on your PC that's all.

Posted: Sat Jul 23, 2005 12:20 pm
by tomE
i don't think i have one running no. How can you tell if i have one or not? Are there any security measures i should be taking to stop this illicit viewing of my OS?

Posted: Sat Jul 23, 2005 4:06 pm
by Chris Corbyn
tomE wrote:i don't think i have one running no. How can you tell if i have one or not? Are there any security measures i should be taking to stop this illicit viewing of my OS?
Excuse me? :? Viewing your PC? I just asked if you had an SMTP server running because you'll need one to send mail from an SMTP server on localhost:25

Here... when you configure outlook, evolution, or whatver email software you send emails from what server address do you put in the SMTP settings (to send email)?

Once you know that, open php.ini and find the line

Code: Select all

SMTP=localhost
Change localhost to the address of your SMTP server. If you're unsure then just try:

smtp.<your_isp's_domain_here>.com --> this is fairly standard but will vary between ISP's.

If you don't know what your SMTP server is or what one does I suggest googling for "SMTP servers" or asking your ISP before attempting to send an email through one ;)

Posted: Sat Jul 23, 2005 5:58 pm
by bokehman
On php/windows you can only send mail via servers that don't require a password (not many).

Posted: Sat Jul 23, 2005 7:39 pm
by timvw
http://phpmailer.sourceforge.net/ has a SMTP class too ;))

Posted: Sat Jul 23, 2005 9:49 pm
by Roja
bokehman wrote:On php/windows you can only send mail via servers that don't require a password (not many).
Sorta true.. php's mail() function doesn't support it, but there is a pear class that does, and there is also the always-fantastic phpmailer. In both cases you can.

However, the original poster sounds like he doesn't have a smtp server running on his machine, so cannot send as a result.

Also, if he sets it to use his isp's smtp server, they have to allow such things, which isn't always true.

Posted: Sun Jul 24, 2005 3:01 am
by bokehman
For just these cases I have write a script so you don't need a mail server at all. It just sends the mail to the remote mailserver directly. That way no username or password is required and there are no worries configuring your mail server because you don't use it.