Re: SMTP-access with PHP...

From: Date: Wed, 20 Jun 2001 17:54:18 +0000
Subject: Re: SMTP-access with PHP...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-54578@lists.php.net to get a copy of this message
The SMTP server that you are using is more then likely configured to deny sending if the e-mail does not originate from the domain the SMTP server is used for. This is done mainly to keep spammers from using the server as an open relay and spewing junk mail all over the internet.... Sometimes system admins will also exclude localhost because they believe that no e-mail should be originating from the mail server itself.... If the e-mail destination is in the domain that this server receives e-mail for it will usually be accepted, otherwise depending upon it's ruleset, it will be denied. Your options are this... 1. Your SMTP server may require authentication before it will allow you to relay. If so then you will need to authenticate yourself as a user, and then it should allow you to relay. 2. If you do not have control of the SMTP server configuration, contact your system admin and see if you can work out a method for you to get the configuration modified to allow you to relay, or if there are other options for relaying. 3. If you have control of the SMTP server, and it is on a RedHat 7.1 machine, read the release notes. In 7.1 RedHat made the sendmail daemon work more or less in receive-only mode (it can be reconfigured to work correctly). If it is not a RedHat box, you will need to reconfigure it to allow relaying... Directions on how to do this can be obtained from www.sendmail.org, or by watching the comp.mail.sendmail newsgroup. ( NOTE: I highly recommend reading the manual and the FAQ before posting a question to the newsgroup, typically you will get flamed if you do not. ) Ed Brady mailinglist@NOMORESPAM.ebrady.net To reply, you know what to remove.... ----- Original Message ----- From: "Magnus Hammar" <magnus@programmering.nu> To: <php-general@lists.php.net> Sent: Wednesday, June 20, 2001 9:16 AM Subject: [PHP] SMTP-access with PHP... > Hello! > > Why do I get this error (Relaying denied ) from my SMTP-server and how do I > make it work? > ---------------------------- > 220 mail.server.com ESMTP Sendmail 8.9.3/8.9.3; Wed, 20 Jun 2001 15:09:06 > +0200 (CEST) > 250 mail.server.com Hello localhost [127.0.0.1], pleased to meet you > 250 magnus@server.com... Sender ok > 550 magnus@programmering.nu... Relaying denied > 503 Need RCPT (recipient) > > Is there something else I can do to make it work? > I use this code: > ----------------------------- > $smtp_server = "localhost"; > $port_number = 25; > $smtp_connection = fsockopen($smtp_server, $port_number); > if(!$smtp_connection){ > $smtp_connection = fopen($smtp_server.":$port_number","w"); > } > if(!$smtp_connection){ > $return_value = "SMTP-server not responding!"; > return 0; > }else{ > fputs($smtp_connection, ""); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fputs($smtp_connection, "HELO $smtp_server\n"); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fputs($smtp_connection, ""); > fputs($smtp_connection, "MAIL FROM: $from\n"); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fputs($smtp_connection, ""); > fputs($smtp_connection, "RCPT TO: $till\n"); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fputs($smtp_connection, ""); > fputs($smtp_connection, "DATA\n"); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fputs($smtp_connection, "Subject: $subjekt\n"); > fputs($smtp_connection, "Reply-To: $from\n"); > fputs($smtp_connection, "MIME-Version: 1.0\n"); > fputs($smtp_connection, "Content-Type: text/plain; charset=iso-8859-1\n"); > fputs($smtp_connection, "Content-Transfer-Encoding: 8bit\n"); > fputs($smtp_connection, "X-mailer: Magnus Mail"); > fputs($smtp_connection, "\n\n"); > fputs($smtp_connection, "$bodyn\n\r"); > fputs($smtp_connection, ""); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fputs($smtp_connection, ""); > fputs($smtp_connection, "QUIT\n\r"); > $return_value = $return_value.fgets($smtp_connection,128)."<br>"; > fclose($smtp_connection); > return $return_value; > > > /Magnus Hammar > -------------- >

« previous php.general (#54578) next »