<?php 
$smtp_server = "mail.webhostasp.com"; 
$port = 25; 
$mydomain = "domain.com"; 
$username = "info@domain.com";
$password = "password"; 
$sender = "info@domain.com"; 
$recipient = "no-one@domain.com";
$subject = "Test";
$content = "Bla bla bla";

// SMTP connection 
$handle = fsockopen($smtp_server, $port); 
fputs($handle, "EHLO " . $mydomain . "\r\n"); 

// SMTP authorization 
fputs($handle, "AUTH LOGIN\r\n"); 
fputs($handle, base64_encode($username)."\r\n"); 
fputs($handle, base64_encode($password)."\r\n"); 

// Send out the e-mail 
fputs($handle, "MAIL FROM:<" . $sender . ">\r\n"); 
fputs($handle, "RCPT TO:<" . $recipient . ">\r\n"); 
fputs($handle, "DATA\r\n"); 
fputs($handle, "To: " . $recipient . "\n"); 
fputs($handle, "Subject: " . $subject . "\n\n"); 
fputs($handle, $content . "\r\n"); 
fputs($handle, ".\r\n"); 

// Close connection to SMTP server 
fputs($handle, "QUIT\r\n"); 
?>

this code works only once, then dos NOT work anymore on my server.
anyone has idea??

fatihpiristine
Deleted Member

i have had problems before where if i didn't close the connection it wouldn't work again. maybe adding "fclose($handle);" will help.

i tried but no success...

anyway.. i solved the problem.. if you need the codes supported with attachments send me pm...

This question has already been answered. Start a new discussion instead.