dezkit Posted August 27, 2007 Share Posted August 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted August 27, 2007 Share Posted August 27, 2007 This should work: <?php $to = "email@address.com"; $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 Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
dezkit Posted August 27, 2007 Author Share Posted August 27, 2007 THANK YOU VERY MUCH DRAGEN. I LOVE YOU! Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 hehe. glad I could help Quote Link to comment Share on other sites More sharing options...
dezkit Posted August 27, 2007 Author Share Posted August 27, 2007 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 Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
dezkit Posted August 27, 2007 Author Share Posted August 27, 2007 damnit >< it doesnt work. This is what comes up in my email: This person likes you, his name is <br />username: <br />password: Quote Link to comment Share on other sites More sharing options...
dezkit Posted August 27, 2007 Author Share Posted August 27, 2007 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.