Page 1 of 1

PHP Mail() Error

Posted: Sat Nov 20, 2010 6:43 pm
by Withers
Hi, all. I've been trying to get the mail() function to work; to send mails off. I changed my php.ini file to say SMTP = mail.domainname. After I did this, I thought it would send off my email script. But an error message came up:

Warning: mail() [function.mail]: SMTP server response: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1) in...

Apparently I need to authenticate in order for my script to send off the email correctly.

How do I authenticate my emails without using a program such as PHPmailer to authenticate it for me? Is that possible?

Re: PHP Mail() Error

Posted: Sun Nov 21, 2010 1:00 pm
by Pazuzu156
Is this for your custom website as a sort of webmail project you are working on or a simple php code to send a message to another person's email with?

Re: PHP Mail() Error

Posted: Sun Nov 21, 2010 9:59 pm
by Pazuzu156
If you want to set up a php mail form, that's really simple. Just use the following below. I'll put explanations within the code so you can better understand how an email form is laid out. This is a simple and insecure way to go about this, but is the easiest:

Code: Select all

<?php

echo "<h1>PHP E-Mail Form Page</h1>";

//start if statement for a submit button inside the form
if(isset($_REQUEST['submit'])) {
    //set variables for the form
    $email = $_REQUEST['email'];
    $subject = $_REQUEST['subject'];
    $message = $_REQUEST['message'];
    //send message with php command mail()
    mail("youremail@domain.com","Subject :$subject",$message,"From: $email");
    //send echo and refresh page(easy end-user help)
    echo "Thanks for contacting us.<meta http-equiv='refresh' content='2'>";
}

//echo out an html table and form.
echo "
<form action='email.php' method='POST'>
<table>
  <tr>
    <td width='18%'>
      E-Mail:
    </td>
      Subject: 
    <td>
      <input type='text' name='subject' size='51'>
    </td>
  </tr>
  <tr>
    <td>
    </td>
    <td>
      <input type='text' name='email' size='51'>
    </td>
  </tr>
  <tr>
    <td valign='top'>
      Message:<br />
      <span style='font-size:9pt;'>Max 250 Characters</span>
    </td>
    <td>
      <textarea cols='40' rows='5' name='message' maxlength='250'></textarea><br />
      <input type='submit' value='Submit' name='submit' />
    </td>
  </tr>
</table>
</form>
";

?>
This should work as I use this for my own website. Play around with it some.