I have mail account on Hotpop . I want to use it to send emails using mail(), already, during php installation I entered the smtp of hotpop and my email on it, but where and How can I entered the password and the user name, Is it in php.ini? or inside my script?
The following code, generates an error, " Warning: Server Error in \multi\mail.php on line 4 ",

<?php
//message format is assigned to variable
$mes = "<html><head><title>Test No 1</title></head><body><center><h1><font color=red>Welcome in the test no 1</body></html>";

//The following line which causes the warrning message
if(mail("said_fox@softhome.net","Hello php test no 1","$mes"))
{
echo("message sent");

}
else
{
echo("It is not sent");
}
?>

Note: My OS is Win ME, PHP Ver 4.2, installed with windows installer, running on Apache server

regards

😕

    Sorry to say this but you cannot have a mail() in an if

    try this

    $mail=@mail(your stuf);
    if(!$mail)
    {
    echo"Mail Not Sent";
    }
    else
    {
    echo"mail sent";
    }

      the SMTP server need verify if you send mail for forbidding spam email.

      you can make your own SMTP server.

        Originally posted by planetsim
        Sorry to say this but you cannot have a mail() in an if

        I beg to differ; if mail() returns true or false there's no a priori reason why it can't be used as the test in an if statement.

        But I thought about this, and reckoned I might try and find something that would work. I thought for a tick about socket connections and doing SMTP protocol by hand, but decided that someone else must've already done so; there'd have to be classes or suchlike out there already for this. So I went looking, and this is what I found. Note the caveat at the end.

        Consider using the PEAR implementation of SMTP. This will allow you much better control over how you communicate with your mailserver.

        This code snippet is straight from the PEAR documentation - I just added an extra comment or so.

        include('Mail.php'); // I'm assuming your PEAR directories are in your
        		     // include path
        
        // The next five lines describe the email itself. $recipients can be an
        // array of addresses, if you want.
        $recipients = 'joe@example.com';
        $headers['From']    = 'richard@phpguru.org';
        $headers['To']      = 'joe@example.com';
        $headers['Subject'] = 'Test message';
        $body = 'Test message';
        
        
        // The next three lines specify your server.
        $params['host']     = ''; // insert your SMTP host's domain
        $params['username'] = ''; // insert your username here
        $params['password'] = ''; // insert your password here
        
        
        // Create the mail object using the Mail::factory method
        $mail_object =& Mail::factory('smtp', $params);
        
        // Send the blessed thing.
        $mail_object->send($recipients, $headers, $body);
        

        I've never done this. I didn't write it. I didn't test it. Not my fault if it barfs.

          Write a Reply...