MyBB Community Forums

Full Version: PHP Help with a Snippet
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey, I have this PHP snippet, where if you load the code, it sends out the content as an email:

<?php
mail( "[email protected]", "Email Title", "Email Content", "[email protected]" );
?>

It all works great, except instead of sending from '[email protected]', it sends from the default host mailer and ads the from email into the body of the email.

Can anybody help me out?
Have you implemented it in your forum's page, If yes, then it will work along with the default settings in the Admin CP,
Change your default outgoing email to your desired email address ant that too written in that snipet

regards
Maybe it is an anti-spam measure put in place by your hosting provider. Are you on a free host?
No, I'm on a VPS by ServInt. This is not related to MyBB.
Try this structure and see if it works:

mail( $to, $subject, $msg,"From:".$_POST['name']." <".$_POST['email'].">\nX-Sender: <".$_POST['email'].">\nX-Priority: 1\nReturn-Path: <".$_POST['email'].">\nContent-Type: text/html; charset=iso-8859-1\n" );

It's not one I've used myself, but only because when I've been needing to use php mail functions I've been doing so in another application, so it just meant that I needed to use their existing function instead.
Where do I input the values?
Assuming that you know some php, it should be self explanatory.

$to = the address the email is going to
$subject = the email subject
$msg = the email message
$_POST['name'] = the senders name
$_POST['email'] = the senders email

It's a structure, not the line of code to put in your code. Use that structure for your mail line and see what happens.
I tried, it didn't send anything.
Did you replace the variables with the correct ones you are using in your code?
Yes I did.
Pages: 1 2