Jump to content

Need Help


dezkit

Recommended Posts

How do i do so i can put php in email scripts? for example

 

<?php
$to = "me@Myself.com";
$subject = "hi sir";
$body = "This person likes you, his name is <?php echo $_POST["name"]; ?>";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>

what is wrong with that? why can't i send an email using php?

thanks to anyone who responds.

 

Link to comment
Share on other sites

you shouldn't use the <?php text inside a variable definition..

<?php
$to = "me@Myself.com";
$subject = "hi sir";
$body = "This person likes you, his name is " . $_POST["name"];
if (mail($to, $subject, $body)) {
  echo "<p>Message successfully sent!</p>";
} else {
  echo "<p>Message delivery failed...</p>";
}
?>

Link to comment
Share on other sites

Wait one second lol

 

<?php
$to = "me@Myself.com";
$subject = "hi sir";
$body = "This person likes you, his name is " . $_POST["name"];
if (mail($to, $subject, $body)) {
  echo "<p>Message successfully sent!</p>";
} else {
  echo "<p>Message delivery failed...</p>";
}
?>

 

How do i make multiples? For example :

 

Username: (php code)<br>

Password: (php code)<br>

etc

Link to comment
Share on other sites

like this?

<?php
$to = "me@Myself.com";
$subject = "hi sir";
$body = "This person likes you, his name is " . $_POST["name"] . "<br />";
$body .= "username: " . $VARIABLE_FOR_USERNAME . "<br />password: " . $VARIABLE_FOR_PASSWORD;
// note: the .= above means that it is added to the end of the $body variable, instead of writing over it.

if (mail($to, $subject, $body)) {
  echo "<p>Message successfully sent!</p>";
} else {
  echo "<p>Message delivery failed...</p>";
}
?>

Link to comment
Share on other sites

nevermind i coded myself. thanks again haha.

and another problem... lol

 

i cant use

<br />

 

<?php
$to = "me@msas.com";
$subject = "hi sir";
$body = "Username: " . $_POST["username"] . "<br />Password: " . $_POST["password"];
if (mail($to, $subject, $body)) {
  echo "<p>Message successfully sent!</p>";
} else {
  echo "<p>Message delivery failed...</p>";
}
?>

Link to comment
Share on other sites

This should enable hte use of html

<?php
$headers = "MIME-Version: 1.0\r\n" .
      "Content-Type: text/html;\r\n";

$to = "me@msas.com";
$subject = "hi sir";
$body = "Username: " . $_POST["username"] . "<br />Password: " . $_POST["password"];
if (mail($to, $subject, $body, $headers)) {
  echo "<p>Message successfully sent!</p>";
} else {
  echo "<p>Message delivery failed...</p>";
}
?>

Link to comment
Share on other sites

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.