Jump to content

Need Help


dezkit

Recommended Posts

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

 

<?php
$to = "[email protected]";
$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
https://forums.phpfreaks.com/topic/66934-need-help/
Share on other sites

This should work:

 

<?php

$to = "[email protected]";
$subject = "Subject";
$message = "Message to email";

if(mail($to, $subject, $message)) {
  echo "Message sent";
} 
else {
echo "Message failed";
}
?>

 

Is there any errors with that? and do you have STMP {Simple transfer mail protocol} set up

Link to comment
https://forums.phpfreaks.com/topic/66934-need-help/#findComment-335577
Share on other sites

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

<?php
$to = "[email protected]";
$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
https://forums.phpfreaks.com/topic/66934-need-help/#findComment-335595
Share on other sites

Wait one second lol

 

<?php
$to = "[email protected]";
$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
https://forums.phpfreaks.com/topic/66934-need-help/#findComment-335610
Share on other sites

like this?

<?php
$to = "[email protected]";
$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
https://forums.phpfreaks.com/topic/66934-need-help/#findComment-335617
Share on other sites

nevermind i coded myself. thanks again haha.

and another problem... lol

 

i cant use

<br />

 

<?php
$to = "[email protected]";
$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
https://forums.phpfreaks.com/topic/66934-need-help/#findComment-335647
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 = "[email protected]";
$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
https://forums.phpfreaks.com/topic/66934-need-help/#findComment-335675
Share on other sites

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.