Kyriakos
Oct 3rd 2008, 1:56 am
hi guys,
i have a php mail script with smtp authontication:<?php
$from = "DEFTEC <info@deftec.gr>";
$to = "rallystas13@hotmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "89.234.63.108";
$username = "info@deftec.gr";
$password = "7791dima";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>the error message is this:Fatal error: Undefined class name 'mail' in C:\inetpub\vhosts\deftec.gr\httpdocs\mail.php on line 14line 14 is this $smtp = mail::factory('smtp',
can anybody help me?
kmap
Oct 3rd 2008, 2:01 am
hi
It wont work in windows enviornment
Check this
http://groups.google.com/group/comp.lang.php/browse_thread/thread/b07212a5e9d38402
You need to use some other package that works in windows env
Regards
Alex
singh.ajit05
Oct 3rd 2008, 5:26 am
try using this
<?php
// Setup
$fromName = "Brian Salter";
$fromEmail = "ns-survey@kcl.ac.uk";
$fromMailer = "Socketmail v2.0";
$smtp = "smtp.kcl.ac.uk";
$smtp_port = 25;
$charset = "ISO-8859-1";
$toArray = file('Test data.csv'); // Read the whole file into an array
// The file is in the format EMAIL, SCJ_CODE, SCE_SRTN
$subject = "National Student Survey";
$baseMessage="
Reasons for non-participation (reply to ns-survey@kcl.ac.uk).
***SCJ_CODE SCE_SRTN
I confirm that I do not wish to participate in the National Student Survey [ ]
My reason for not participating is (please mark one of the following boxes and delete the other options):
a)[ ] I do not wish my personal details to be used for the purposes of this survey
b)[ ] I believe that participation will exacerbate my health difficulties
c)[ ] I believe I have been wrongly selected for inclusion in the survey.
Please note that instead of passing your personal contact details through to HEFCE/Ipsos, the above reason, in coded form, will be passed
through instead.
";
// Strip "\r" from the message (if it came from a form input)
$baseMessage = str_replace(chr(13), "", $baseMessage);
$baseMessage = str_replace("\r\n.", "\r\n..", str_replace("\n", "\r\n", stripslashes($baseMessage))." \r\n");
ini_set('sendmail_from', $fromEmail);
$connect = @fsockopen ($smtp, $smtp_port, $errno, $errstr, 5);
if (!$connect) return false;
$rcv = fgets($connect, 1024);
// fputs($connect, "HELO {$_SERVER['SERVER_NAME']}\r\n");
fputs($connect, "HELO 127.0.0.1\r\n");
$rcv = fgets($connect, 1024);
foreach ($toArray as $to) {
$toBits = explode(",", $to);
$toRcpt = trim($toBits[0]);
$SCJ_CODE = $toBits[1];
$SCE_SRTN = $toBits[2];
$searchFor = array("SCJ_CODE", "SCE_SRTN");
$replaceWith = array($SCJ_CODE , $SCE_SRTN );
$message = str_replace($searchFor, $replaceWith, $baseMessage);
fputs($connect, "RSET\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "MAIL FROM:$fromEmail\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "RCPT TO:$toRcpt\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "DATA\r\n");
$rcv = fgets($connect, 1024);
fputs($connect, "Subject: $subject\r\n");
fputs($connect, "From: $fromName <$fromEmail>\r\n");
fputs($connect, "To: $toRcpt\r\n");
fputs($connect, "X-Sender: <$fromEmail>\r\n");
fputs($connect, "Return-Path: <$fromEmail>\r\n");
fputs($connect, "Errors-To: <$fromEmail>\r\n");
fputs($connect, "Message-Id: <".md5(uniqid(rand())).".".preg_replace("/[^a-z0-9]/i", "", $fromName)."@$smtp>\r\n");
fputs($connect, "X-Mailer: PHP - $fromMailer\r\n");
fputs($connect, "X-Priority: 3\r\n");
fputs($connect, "Date: ".date("r")."\r\n");
fputs($connect, "Content-Type: text/plain; charset=$charset\r\n");
fputs($connect, "\r\n");
fputs($connect, $message);
fputs($connect, "\r\n.\r\n");
$rcv = fgets($connect, 1024);
}
fputs ($connect, "QUIT\r\n");
$rcv = fgets ($connect, 1024);
fclose($connect);
ini_restore('sendmail_from');
?>
Sillysoft
Oct 3rd 2008, 5:54 am
hi guys,
i have a php mail script with smtp authontication:<?php
$from = "DEFTEC <info@deftec.gr>";
$to = "rallystas13@hotmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "89.234.63.108";
$username = "info@deftec.gr";
$password = "7791dima";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>the error message is this:line 14 is this $smtp = mail::factory('smtp',
can anybody help me?
PHPMailer is a great class to use for emailing, especially when using SMTP authentication:
http://phpmailer.codeworxtech.com/
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.