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
https://forums.phpfreaks.com/topic/185068-php-mail-rejected-by-smtp/
Share on other sites

authenticate  ur mail using this one

 <?php
    require_once "Mail.php";

    $from = "Chaitu <[email protected]>";
    $to = "Chaitu <[email protected]>";
    $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

just check these artilces which can help u out

http://www.cyberciti.biz/tips/rhel-install-php-net-smtp-email-socket.html

http://pear.php.net/manual/en/guide.users.commandline.installing.php

 

also when u open php.ini it should have this line uncommented.

include_path = ".;C:\xampp\php\PEAR"

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!

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.