vijdev Posted April 25, 2010 Share Posted April 25, 2010 can someone pls tell me why doesnt the below code work? i get an error: SMTP server response: 504 Authenticate first (#5.5.0) i have set the smtp server name in my php.ini ####################php.ini############# [mail function] ; For Win32 only. SMTP =mail.xyz.com smtp_port = 25 ; For Win32 only. sendmail_from [email protected] ###############code########################## <?php if (isset ($_POST['submit'])) { $name=$_POST['name']; $message=$_POST['text']." ".$_POST['text']; $to=$_POST['email']; $headers="From: [email protected]"; $subject="Test Mail"; mail ( $to , $subject , $message, $headers); } ?> <html> <head> <title>Say My Name</title> </head> <body> <form action="mailvij.php" method="post"> <table> <tr> <td>Name</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" ></td> </tr> <tr> <td>Text</td> <td><textarea name="text" rows=5 cols=10></textarea></td> </tr> <tr> <td colspan="2" style="text-align: center;"> <input type="submit" name="submit" value="Submit" /></td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/ Share on other sites More sharing options...
cags Posted April 25, 2010 Share Posted April 25, 2010 The SMTP server you are trying to use 'mail.xyz.com' requires authentication. The PHP mail function does not support authentication. You will have to either use a different SMTP server or use a different mail class such as PEAR Mail or PHP Mailer. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1047932 Share on other sites More sharing options...
vijdev Posted April 25, 2010 Author Share Posted April 25, 2010 now does this authentication come from: 1.the mail class setup 2.or something to do in the form script 3.or in php.ini and what kind of authentication would it be?...is it the password thats used to access [email protected] inbox? Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1048059 Share on other sites More sharing options...
cags Posted April 25, 2010 Share Posted April 25, 2010 None of the above. The SMTP server requires you to authenticate with it before you can send e-mails. The mail function is contacting mail.xyz.com saying "Please send this e-mail", the SMTP is sending a message back saying "No, you have to login before you can send an e-mail". Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1048061 Share on other sites More sharing options...
vijdev Posted April 26, 2010 Author Share Posted April 26, 2010 Cags, thanks for the replies.however i am afraid i need some more spoon-feeding!..if anything more that can help me understand this better. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1048441 Share on other sites More sharing options...
cags Posted April 26, 2010 Share Posted April 26, 2010 I don't see how I can make it any more clear. The mail.xyz.com is blatantly not the actual value you are using in your php.ini. Whatever SMTP server you are using requires you to authenticate with it before you can send an e-mail, this CANNOT be done with the mail function, it does not support authentication. You either need to use an SMTP server that doesn't require authentication or use a different mailing class such as one of the two I mentioned previously. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1048444 Share on other sites More sharing options...
vijdev Posted April 26, 2010 Author Share Posted April 26, 2010 just to clarify myself mail.xyz.com...here i have the actual SMTP server..not xyz but i dont understand the authentication part!.....hmmmmmmmmmm! how do i differentiate or know if an smtp server needs or does not need authentication? Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1048485 Share on other sites More sharing options...
PFMaBiSmAd Posted April 26, 2010 Share Posted April 26, 2010 Sounds to me like the From: address you are using is not hosted at the sending mail server so the mail server thinks you are trying to relay email through it and it is requiring that SMTP Authentication be used. Is the From: address hosted at the sending mail server? It should be, which will also likely eliminate the need to use SMTP Authentication. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1048499 Share on other sites More sharing options...
vijdev Posted April 27, 2010 Author Share Posted April 27, 2010 yes the from address is that which belongs to the SMTP server Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049103 Share on other sites More sharing options...
cags Posted April 27, 2010 Share Posted April 27, 2010 We are guessing blind as you won't tell us what server you are using. My guess is you are trying to use a service such as gmail, which always requires authentication. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049172 Share on other sites More sharing options...
vijdev Posted April 27, 2010 Author Share Posted April 27, 2010 its my own domain, and for certain reasons am bound from telling what it its. it is hosted on a shared hosting,the mail belongs to the same domain as is the mail server. it is not gmail. i am only looking on some elaborate information on what is meant by "authentication". if a mail server requires authentication, how does one do it? Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049199 Share on other sites More sharing options...
Deoctor Posted April 27, 2010 Share Posted April 27, 2010 dude just try this code. this will work u have to autenticate ur mail or else ur mail sever thinks that some one is useing it without a valid username and password. this is called as ssl in plain terms.. <?php require_once "Mail.php"; $from = "[email protected]"; $to = "[email][email protected][/email]"; $subject = "Hi!"; $body = "<h1>Hi</h1>,\n\nHow are you?"; $host = "mail.example.com"; $username = "smtp_username"; $password = "smtp_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); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> note: you should have pear installed in your machine already to use this.. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049212 Share on other sites More sharing options...
vijdev Posted April 27, 2010 Author Share Posted April 27, 2010 does this need PEAR? Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049217 Share on other sites More sharing options...
Deoctor Posted April 27, 2010 Share Posted April 27, 2010 yes that is what i told right note: you should have pear installed in your machine already to use this.. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049221 Share on other sites More sharing options...
vijdev Posted April 27, 2010 Author Share Posted April 27, 2010 aaah ok...didnt notice that! Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1049225 Share on other sites More sharing options...
jetjock99 Posted November 26, 2016 Share Posted November 26, 2016 Any chance, since I am getting the same message, but actually am getting a message prior to this one. When I code require_once 'Mail.php'; I get an error message saying that a stream couldn't be created (something like that). I know for a fact that Mail.php cannot be found on my computer at all. I need to know how to (I think) to install the Mail part of PEAR. I believe that's the problem, that pear install Mail has not been done, but the more I read, the more I'm confused as to how to do this one part of PEAR. Help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/199658-mail-not-working-smtp-server-response-504-authenticate-first-550/#findComment-1539693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.