Jump to content

Can I get help on a Newsletter Script from Anybody Here?


Recommended Posts

Hi,
    I am trying to set up a newsletter script but it is saying cannot send newsletter.Please I need urgent help.
here is the code

Code:
<?php
 
  $message= "header.tpl".$contents."footer.tpl";
  ?>
<?php
// connecting to MySQL server
$connection = mysql_pconnect('localhost', '', '')
or die ('Unable to connect!');
// selecting database for use
mysql_select_db('db') or die ('Unable to select database!');
// create and execute query
$query = 'SELECT email FROM newsletter';
$result = mysql_query($query)
or die ('Error in query: $query. ' . mysql_error());
// check if records were returned
if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result))
  $toAddress=$result;
  $subject=$header."\n";
  //error suppressed,remove it to see what happens
  @$success=mail($toAddress,$subject,$message);
}
if($success){
print "Newsletter Sent";
            }
else{
      echo'Newwsletter could not be sent';
  }   
// once processing is complete
// free result set
mysql_free_result($result);
           
?>
Please I will appreciate your help.
Thanks
Did you copy this code from somewhere?  The comments are telling you exactly what to do...

[quote author=xux link=topic=109406.msg440873#msg440873 date=1159191071]
  //error suppressed,remove it to see what happens
  @$success=mail($toAddress,$subject,$message);
[/quote]

Remove the @ from the front of the line and see if it helps.

Regards
Huggie
Hi,
    After trying out the suggestion given to me,the script is still not working.It it a bit complicated because I want to send the newsletter in html format,it would have been easier in plain language but html is the required format.so please what help/suggestion are you going to give.Thanks
I've just broken the code down and tried the following to my hotmail.co.uk address and not only did it arrive ok, but it went into the inbox as opposed to the junk mail.

Try copying and pasting this code into a page and seeing if it works, just replace the toAddress.

[code]
<?php
  $message = "<h1>Test HTML email</h1><img src=\"http://www.dizzie.co.uk/myspace/sig.gif\" alt=\"Signature\">";

  // Set some parameters
  $toAddress = "myemailaddress@hotmail.co.uk";
  $subject = "Test Subject";
  $headers = "Content-type: text/html\n\n";

  // Try to send the message
  $success = mail($toAddress,$subject,$message,$headers);

  if($success){
      print "Newsletter Sent";
  }
  else{
      echo'Newwsletter could not be sent';
  } 
?>
[/code]

Assuming that this works ok then add bits to it gradually.

Regards
Huggie
Hi,
    I tested your code and it work perfectly alright,but it was send to the junk of my yahoo.On getting to my junk,i actually found out that the code i posted(the one I felt was not working) have been sending
[code]header.tplfooter.tpl[/code]
to the my email(I was using it to test the code),so i think I hve isolated the problems which I hope you will be kind enough to help me solve
1.The code has not been grabbing the header(an image),the content and the footer (which is an image too)
2.It has been echoing "Newsletter can not be sent" while it have been sending it
Am sure you will be able to help me out on it.
Thanks a lot,I appreciate your help.
My Regards
Dayo

Hi,
    I tested your code and it work perfectly alright,but it was send to the junk of my yahoo.On getting to my junk,i actually found out that the code i posted(the one I felt was not working) have been sending

[code]header.tplfooter.tpl[/code]

to the my email(I was using it to test the code),so i think I hve isolated the problems which I hope you will be kind enough to help me solve
1.The code has not been grabbing the header(an image),the content and the footer (which is an image too)
2.It has been echoing "Newsletter can not be sent" while it have been sending it
Am sure you will be able to help me out on it.
3.Sending the newsletter to the emails stored in the database
Thanks a lot,I appreciate your help.
My Regards
Dayo

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.