Jump to content

PHP mail() rejected by SMTP


Vebut

Recommended Posts

I'm currently working on a newsletter application which is installed on a windows 2003 server running apache. This server is scheduled to run a script every 5 minutes that will send an email to 10 individuals during each iteration. It all works fine when sending to emails registered with our mail server but when sending to external addresses I get a 550 error from the smtp.

 

I've setup these settings in php.ini:

smtp = mail.*public_domain*.se

smtp_port = ****

username = *noreply email account*

password = *******

 

sendmail_from = *same as username*

 

Is there something obvious i'm missing here? :)

Thanks!

 

Edit: Not IIS, its apache :)

Link to comment
Share on other sites

authenticate  ur mail using this one

 <?php
    require_once "Mail.php";

    $from = "Chaitu <drvirusindia@gmail.com>";
    $to = "Chaitu <drvirusindia@gmail.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    $host = "ssl://mail.example.com";
    $port = "465";
    $username = "smtp_username";
    $password = "smtp_password";

    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'port' => $port,
        '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>");
     }
    ?>

 

might be it will help u out.

just check whether PEAR installed in ur machine

Link to comment
Share on other sites

I installed pear (go-pear.bat) and then installed the mail package using command line: "pear install mail" but when I try to use the Mail class inside of my application it can not locate the class. SPL should load it right?

Link to comment
Share on other sites

Ok, now I've got the Mail class working but when using factory I get a fatal error:

Fatal error: Class 'Net_SMTP' not found in D:\wamp\bin\php\php5.2.11\PEAR\Mail\smtp.php on line 210

 

Edit: Never mind, I installed the Net_SMTP package as well and now its working just fine. Thanks for all the help!

Link to comment
Share on other sites

open ur smtp.php file and change the values

class Mail_smtp extends Mail {

    /**
     * SMTP connection object.
     *
     * @var object
     * @access private
     */
    var $_smtp = null;

    /**
     * The SMTP host to connect to.
     * @var string
     */
    var $host = 'localhost';

    /**
     * The port the SMTP server is on.
     * @var integer
     */
    var $port = 25;

    /**
     * Should SMTP authentication be used?
     *
     * This value may be set to true, false or the name of a specific
     * authentication method.
     *
     * If the value is set to true, the Net_SMTP package will attempt to use
     * the best authentication method advertised by the remote SMTP server.
     *
     * @var mixed
     */
    var $auth = false;

    /**
     * The username to use if the SMTP server requires authentication.
     * @var string
     */
    var $username = '';

    /**
     * The password to use if the SMTP server requires authentication.
     * @var string
     */
    var $password = '';

    /**
     * Hostname or domain that will be sent to the remote SMTP server in the
     * HELO / EHLO message.
     *
     * @var string
     */
    var $localhost = 'localhost';

    /**
     * SMTP connection timeout value.  NULL indicates no timeout.
     *
     * @var integer
     */
    var $timeout = null;

    /**
     * Whether to use VERP or not. If not a boolean, the string value
     * will be used as the VERP separators.
     *
     * @var mixed boolean or string
     */
    var $verp = false;

    /**
     * Turn on Net_SMTP debugging?
     *
     * @var boolean $debug
     */
    var $debug = false;

    /**
     * Indicates whether or not the SMTP connection should persist over
     * multiple calls to the send() method.
     *
     * @var boolean
     */
    var $persist = false;

indicated to the smtp server which u are using.

 

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.