Jump to content

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


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  :-[

 

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.