adv Posted July 11, 2011 Share Posted July 11, 2011 i have this script below that sends mail using smtp but the thing is this does it keeps all smtp connections open and does it sends from it simultaneously <?php include('SMTPconfig.php'); include('SMTPClass.php'); /* smtps are in file user:pass:host user1:pass1:host1 */ $file=file('smtp.txt'); $smtp_port='25'; $to = '[email protected]'; $from = '[email protected]'; $subject = 'test'; $body = 'hello all'; foreach($file as $files){ list($smtp_user,$smtp_pass,$smtp_server)=explode(':',$files); $SMTPMail = new SMTPClient ($smtp_server, $smtp_port, $smtp_user, $smtp_pass, $from, $to, $subject, $body); $SMTPChat = $SMTPMail->SendMail(); } ?> Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/ Share on other sites More sharing options...
adv Posted July 11, 2011 Author Share Posted July 11, 2011 this is the whole code <?php class SMTPClient { function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body){ $this->SmtpServer = $SmtpServer; $this->SmtpUser = base64_encode ($SmtpUser); $this->SmtpPass = base64_encode ($SmtpPass); $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; if ($SmtpPort == "") $this->PortSMTP = 25; else $this->PortSMTP = $SmtpPort; } function SendMail () { if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) { fputs ($SMTPIN, "EHLO localhost\r\n"); $talk["hello"] = fgets ( $SMTPIN, 1024 ); fputs($SMTPIN, "auth login\r\n"); $talk["res"]=fgets($SMTPIN,1024); fputs($SMTPIN, $this->SmtpUser."\r\n"); $talk["user"]=fgets($SMTPIN,1024); fputs($SMTPIN, $this->SmtpPass."\r\n"); $talk["pass"]=fgets($SMTPIN,256); fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n"); $talk["From"] = fgets ( $SMTPIN, 1024 ); fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n"); $talk["To"] = fgets ($SMTPIN, 1024); fputs($SMTPIN, "DATA\r\n"); $talk["data"]=fgets( $SMTPIN,1024 ); fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n"); $talk["send"]=fgets($SMTPIN,256); //CLOSE CONNECTION AND EXIT ... fputs ($SMTPIN, "QUIT\r\n"); fclose($SMTPIN); } return $talk; } } /* smtps are in file user:pass:host user1:pass1:host1 */ $file=file($argv[1]); if(!$file) die('Cannot open '.$argv[1]); $to = '[email protected]'; $from = '[email protected]'; $subject = 'test'; $body = 'hello all'; foreach($file as $files){ list($smtp_server,$smtp_user,$smtp_pass)=explode(':',$files); $SMTPMail = new SMTPClient ($smtp_server, $smtp_port, $smtp_user, $smtp_pass, $from, $to, $subject, $body); $SMTPChat = $SMTPMail->SendMail(); if($SMTPChat) echo 'mail have been sent to '.$to; } ?> i`ve tried like this but i think its sending it one by one and nothing reaches in mail :| Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/#findComment-1241343 Share on other sites More sharing options...
adv Posted July 11, 2011 Author Share Posted July 11, 2011 at least please can someone tell me if i can open 100 smtp connections from one server and use it to send simultaneously from all 100 ? Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/#findComment-1241486 Share on other sites More sharing options...
Kustom_Vegas Posted July 11, 2011 Share Posted July 11, 2011 I beleive that the max number of concurrent connections is defaulted at 50 This can be changed in your php.ini file, look for "smtp_accept_max" Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/#findComment-1241494 Share on other sites More sharing options...
adv Posted July 11, 2011 Author Share Posted July 11, 2011 thanks for answering vegas but what i did i good ? i mean with foreach function to loop though the entire list of smtp does it keeps it open when it loops over it and does it sends from all simultaneously?? and by the way i dont see any smtp_accept_max in the php.ini Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/#findComment-1241518 Share on other sites More sharing options...
adv Posted July 11, 2011 Author Share Posted July 11, 2011 please anybody who have experience with what i say :| ?? Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/#findComment-1241595 Share on other sites More sharing options...
adv Posted July 12, 2011 Author Share Posted July 12, 2011 ok if nobody knows i`ll make it simple there is ams ( advanced mass sender ) or something like that and it uses multiple smtp`s connections at the same time and its sends from all simultaneously i just wanna know if how can i do that in php thanks Link to comment https://forums.phpfreaks.com/topic/241695-using-smtp/#findComment-1241926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.