I am new to PHP , I have developed about 12 dynamic websites.
My question is how users can scsribe for a monthly newsletter on my websites. Which steps I have to follow.

Thanks:)

Ayesha
Developer

Heya ....

It depends on how complicated you want/need this to be! How many potential subscribers do you expect?

If you have some cash then you could search for one of the many pre made scripts out there and possibly configure it to your liking.

If you want to start from scratch then you can simply add a check box to the sign up page that members can opt in/out for ... then insert their email addy into a database table if they sign up!

The create the code to send via php code that loops through the database rows and sends out an email.

If you want something more detailed and complex then I would advise googling Newsletter script - Mailing lists php script etc

There are even a few mailing list tutorials out there so look around! :)

There are also possibilities on your c-panel/plesk panel if you have a host account to set up mailing lists!

:)

I hope you will develop a sample from these steps:

1. Ask email from the user.
2. Verify the user account by sending an email along with a token (a unique identifier) and a url having a token for a request.
3. When a user request by clicking at url in an email - update user account with confirmed email address. If user account inactive more then a week without confirmation then delete it.
4. Send email to all of those; confirmed members(users).

Okz .
First I have to use an input field for email and a submit button.
Second Step is unfamiliar to me, I do not have knowledge about a token so please guide me with some example.
Third step updation is , I think easy but one week time is difficult for me. and send mail is also difficult for me. if u have developed this please guide and teach me with example and please teach me with step by step. I really love programming. So I want to learn new Technologies and Tools.

Thanks

Ayesha
Developer

Hi

please also suggest any book in which Newsletter example given or any tutorial on web or video and please also give me source about the Newsletter. I have understand the idea.

This file is index.php but i do not know how to include config.php and class.phpmailer ? :(

<?php
if(isset($_POST['emailSubject']) && isset($_POST['emailBody']) && strlen($_POST['emailSubject'])>1 && strlen($_POST['emailBody'])>1 ){
include('config.php');
include('PHPMailer2/class.phpmailer.php');

// Get users info
$getUser_Sql = 'SELECT email FROM USER';
$getUser = mysql_query($getUser_Sql);

// Post Variables
$emailSubject = $_POST['emailSubject'];
$emailBody = $_POST['emailBody'];

while ($row = mysql_fetch_array($getUser)) {
// Get the current user's email
$emailUser = $row['email'];
// Define mail object and mail parameters
$mail = new PHPMailer();
$mail->From = 'name@mysite.com';
$mail->FromName = 'Add your name or your site name here';
$mail->AddAddress($emailUser);
$mail->Subject = $emailSubject;
$mail->Body = $emailBody;
// Send and verify
if(!$mail->Send()) {
echo 'Your message was not sent to '. $emailUser;
echo 'Error is: '. $mail->ErrorInfo;
} else {
echo 'The message has been sent to '.$emailUser;
}
}
}
?>

<form action="index.php" method="post">
<strong>Email Subject</strong><br />
<input name="emailSubject" type="text" size="32" />
<br /><br />
Email text<br />
<textarea name="emailBody" cols="20" rows="6"></textarea>
<br />
<input name="send" type="button" value="Send!" />
</form>

This is a code for newsletter.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
include('config.php');
include('\xampp\php\pear\class.phpmailer.php');

$getUser_Sql	=	'SELECT email FROM USER';
$getUser		=	mysql_query($getUser_Sql);

$emailSubject	=	$_POST['emailSubject'];
$emailBody		=	$_POST['emailBody'];

while ($row = mysql_fetch_array($getUser)) {
	// Get the current user's email
	$emailUser = $row['email'];
	// Define mail object and mail parameters
	$mail = new PHPMailer();
	$mail->From = 'ayesha789@live.com';
	$mail->FromName = 'hi';
	$mail->AddAddress($emailUser);
	$mail->Subject = $emailSubject;
	$mail->Body = $emailBody;
	// Send and verify
	if(!$mail->Send()) {
	   echo 'Your message was not sent to '. $emailUser;
	   echo 'Mailer error: '. $mail->ErrorInfo;
	} else {
	   echo 'The message has been sent to '.$emailUser;
	}
}
?>
<form action="m.php" method="post">
<strong>Email Subject</strong><br />
<input name="emailSubject" type="text" size="32" />
<br /><br />
Email text<br />
<textarea name="emailBody" cols="20" rows="6"></textarea>
<br />
<input name="send" type="button" value="Send!" />
</form>
</body>
</html>

It gives following errors

Warning: include(\xampp\php\pear\class.phpmailer.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\m.php on line 11

Warning: include() [function.include]: Failed opening '\xampp\php\pear\class.phpmailer.php' for inclusion (include_path='.;\xampp\php\pear\') in C:\xampp\htdocs\m.php on line 11

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\m.php on line 19

how to remove these errors. i have changed the file name to m.php
but how to include config and phpmailer class.

When I try to include like this

include('.;\xampp\php\pear\');

it gives error like Parse error: parse error in C:\xampp\htdocs\m.php on line 13 I am confused.

Ayesha

Where did you got this code? Did you wrote yourself? Its an email code.

Dear ayesha789.
Don't waste your time. This (forum) is a not a proper medium to learn new things very fumdamentally. Read books - Try to adjust yourself with a book and do more practice.

Oh no sorry, but you give me link and I follow.
Please tell me the name of any book which is best for beginners level and also easy and if example are given with images then great.
please A Data Post

please reply to my post.

Source code is not a solution of your problem. Create your application and then ask for help if you are unable to solve it.

Comments
thanks for nice suggestion
This article has been dead for over six months. Start a new discussion instead.