Jump to content

Please help me to set up sending emails to users :(


linux1880

Recommended Posts

?php

$to = "[email protected]";

$subject = "hi how are you";

$body = "helllo hello this is test.. this is test ........";

$headers = "From: [email protected]\r\n" .

    "X-Mailer: xxxx LONDON";

if (mail($to, $subject, $body, $headers)) {

  echo("<p>Message sent!</p>");

} else {

  echo("<p>Message delivery failed...</p>");

}

?>

Hello friends,

 

I want to send this email to different users.

 

I already have variables like

 

emails: <?=$row['email_add'] ?>

body: <?=$row['noteforstudents'] ?>

 

I just want different person to receive email according to the details above. Do I need to set up session or require_once for this ?

 

I don't know how to setup pls help

Thanks Edit/Delete Message

I did try

 

<?php
$to = "[email protected]";
$subject = "You have received feedback from LONDON";
$body = $row['noteforstudents'];		
$headers = "From: [email protected]\r\n" .
    "X-Mailer:LONDON";
if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>

 

There is nothing on the message body, how ever, when i just type plain text like "hellow how are you". It goes,

 

dunno what's happening :(

Hi danny,

 

I have another php page which extact the data from the database with this command

<?=$row['noteforstudents'] ?>

 

I thought the same thing will pull out the same information from the database to the email but it's not happening.

 

I put $row as you have taught me but doesn't seem to work :(

I supposed you had already fetched some data and stored it as an array in $row. Although you can do so you'll fetch it just by doing that it wouldn't be a good idea and I doubt that you've done so. You'll have to get the data from the database like you did on the other page.

Thank you sir,

 

$body = $row['noteforstudents'];

 

This code did work on the same page as there are other codings and the mail goes everytime the page refresh.

 

But when i move this page to another php page like something.php it doesn;t pull the data from the database, any help would be greatful

 

<?php
$to = "[email protected]";
$subject = "This is a email feedback from me";
$body = $row['noteforstudents'];
$headers = "From: [email protected]\r\n" .
    "X-Mailer: xxxx LONDON";
if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>  

 

 

If insert the above php mail block code on the original page which has got other variables and forms that mail thing work but when i create another page sendmail.php of this mail and insert the code

<?php
$to = "[email protected]";
$subject = "This is a email feedback from me";
$body = $row['noteforstudents'];
$headers = "From: [email protected]\r\n" .
    "X-Mailer: xxxx LONDON";
if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>  

 

I get empty message .

 

It would be no problem if the mail wouldn't go everytimes I refresh the page while placing the code on the same page so i did put the button referencing

 

<form method="post" action="sendmail.php">
  <div align="center">
    <input type="submit" value="send this email"/>
  </div>
</form>

 

so that if i press the button mail would go to student,

 

no luck  :-[

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.