Member Avatar for fatihpiristine
<?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??

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

Member Avatar for fatihpiristine

i tried but no success...

Member Avatar for fatihpiristine

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.