Hello i'm working on a project and i've reach a dead end. What i'm trying to do with the code is this:
1. Connecting to an external smtp server;
2. Authenticating with login and pass using AUTH LOGIN using an external hostnames file (line-by-line), and external user and password file.
3. Send a email to a predefined email address on file using an external file with the email body.
My problem is that I dont receive any email, what i'm guessing is that the auth login code is broken. Also I want to make a single user and password file using this format user : password. Also I want to make the code do this: to get the first smtp hostname and to login with the users
assword in the external file provided. If unsuccessful login to try the next line in the users : password file. When finished with the login and password to jump to the next hostname in the hostname file.
Here's my work so far:
1. Connecting to an external smtp server;
2. Authenticating with login and pass using AUTH LOGIN using an external hostnames file (line-by-line), and external user and password file.
3. Send a email to a predefined email address on file using an external file with the email body.
My problem is that I dont receive any email, what i'm guessing is that the auth login code is broken. Also I want to make a single user and password file using this format user : password. Also I want to make the code do this: to get the first smtp hostname and to login with the users

Here's my work so far:
Code:
<?php function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) { function loadini($path) { $fp = fopen($path, "r"); fclose($fp); } $message = loadini("message"); $to = "[email protected]"; $from = "[email protected]"; $namefrom = "test"; $subject = "test also"; $nameto = "notme"; authSendEmail($from, $namefrom, $to, $nameto, $subject, $message); ?> //SMTP + SERVER DETAILS /* * * * CONFIGURATION START * * * */ $smtpServer = loadini("logfile");; $port = "25"; $timeout = "30"; $username = loadini("users"); $password = loadini("password"); $localhost = "localhost"; $newLine = "\r\n"; /* * * * CONFIGURATION END * * * * */ //Connect to the host on the specified port $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); $smtpResponse = fgets($smtpConnect, 515); if(empty($smtpConnect)) { $output = "Failed to connect: $smtpResponse"; return $output; } else { $logArray['connection'] = "Connected: $smtpResponse"; } //Say Hello to SMTP fputs($smtpConnect, "HELO $localhost" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['heloresponse'] = "$smtpResponse"; //Request Auth Login fputs($smtpConnect,"AUTH LOGIN" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authrequest'] = "$smtpResponse"; //Send username fputs($smtpConnect, base64_encode($username) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authusername'] = "$smtpResponse"; //Send password fputs($smtpConnect, base64_encode($password) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authpassword'] = "$smtpResponse"; //Email From fputs($smtpConnect, "MAIL FROM: $from" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailfromresponse'] = "$smtpResponse"; //Email To fputs($smtpConnect, "RCPT TO: $to" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailtoresponse'] = "$smtpResponse"; //The Email fputs($smtpConnect, "DATA" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['data1response'] = "$smtpResponse"; //Construct Headers $headers = "MIME-Version: 1.0" . $newLine; $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine; $headers .= "To: $nameto <$to>" . $newLine; $headers .= "From: $namefrom <$from>" . $newLine; fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Say Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } ?>
Comment