Jump to content

mail() not working - SMTP server response: 504 Authenticate first (#5.5.0)


vijdev

Recommended Posts

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 =VK@xyz.com

###############code##########################

<?php

    if (isset ($_POST['submit'])) {

   

    $name=$_POST['name'];

    $message=$_POST['text']." ".$_POST['text'];

    $to=$_POST['email'];

    $headers="From: vk@xyz.com";

    $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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 = "vk@xyz.com";
$to = "[email]yourmail@yaourdomain.com[/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..

 

Link to comment
Share on other sites

  • 6 years later...

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.