db acess details:
host: localhost
username: root
password: <empty>
db name: test
id, username, password, email, create_date, status
I want you to write a class which will fetch all the email address and send an email to all of them with the following:
Subject: Hello there
Message: Hello, dare devil is knocking at your door.
i want to use smtp for sending mail in leau of using php mail().
how i can do it ..?? i will be greatly helpful if i get this class ...
a class which will fetch all the email address and send mail
Moderator: General Moderators
Re: a class which will fetch all the email address and send mail
You could try to do it yourself and I'm sure someone would be more than happy to help you if you get stuck on something.
Re: a class which will fetch all the email address and send mail
Sending Mail from PHP Using SMTP Authentication - Example
<?php
require_once "Mail.php";
$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";
$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>");
}
?>
I CAN DO UPTO THIS NOW PLZ MODIFY IT AND IN A WAY WHERE I WOULD ALSO BE ABLE TO FETCH ALL THE EMAIL ADDRESS FROM SERVER AND SEND MAIL TOO EVERYBODY...
<?php
require_once "Mail.php";
$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";
$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>");
}
?>
I CAN DO UPTO THIS NOW PLZ MODIFY IT AND IN A WAY WHERE I WOULD ALSO BE ABLE TO FETCH ALL THE EMAIL ADDRESS FROM SERVER AND SEND MAIL TOO EVERYBODY...
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Re: a class which will fetch all the email address and send mail
please punch yourself in the face. what do you mean "FETCH ALL THE EMAIL ADDRESS FROM SERVER"?