SMTP Authentication

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
engert100
Forum Newbie
Posts: 3
Joined: Wed Apr 05, 2006 8:49 am

SMTP Authentication

Post by engert100 »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi everyone.

I'm am using a php contact form in my website, which i got from [url=http://www.syndikut.pwp.blueyonder.co.uk/free.htm]here[/url]. Demo [url=http://www.syndikut.pwp.blueyonder.co.uk/free/mailme/email.php]here[/url]. It is working fine, except that when you hit submit it gives me this error:

Code: Select all

Warning: mail(): SMTP server response: 503 This mail server requires authentication. Please check your mail client settings. in c:\inetpub\wwwroot\offline\email.php on line 54
I checked line 54 and it looks like this:

Code: Select all

$send = mail( $to, $subject, $message, "From: {$from}");
Now my question is: What smtp authentication code should i add in this line (or another line) so i can put the name of my SMTP server, Username and Password?

Any help is appreciated.

Thank you.


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
ed209
Forum Contributor
Posts: 153
Joined: Thu May 12, 2005 5:06 am
Location: UK

Post by ed209 »

Not sure if this is any use, but I stumbled across it the other day http://uk.php.net/manual/en/ref.mail.php#39305
engert100
Forum Newbie
Posts: 3
Joined: Wed Apr 05, 2006 8:49 am

Post by engert100 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


And how could i code that into my file? Would it be something like this:

Code: Select all

$send = mail( $to, $subject, $message, "From: {$from}");  
$params["host"] = "smtp.server";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "user";
$params["password"] = "password";

Would that work?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

be extremely careful in passing header information to mail(), you could fall victim to header injection (a.k.a. spammer paradise)

Have a read through the security section to understand how to protect your scripts from it.
engert100
Forum Newbie
Posts: 3
Joined: Wed Apr 05, 2006 8:49 am

Post by engert100 »

Thank you feyd.

Would this page be a good recource for mail protection: http://www.phparch.com/phpsec/ ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I was speaking more specifically look through here. But php|architect is also a good resource to look through.
Post Reply