hoponhiggo Posted June 22, 2011 Share Posted June 22, 2011 Hi Guys I have just got the mail function to work using; //send mail $to = $_POST['email']; $subject = "Welcome"; $message = " <html> <head> <title>Welcome</title> </head> <body> <p>Thank you for registering</p> </body> </html> "; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$message,$headers); but i cant figure out where i need to specify who the mail should be from? At the minute, they are being sent from [email protected] How do i change this? thanks Quote Link to comment https://forums.phpfreaks.com/topic/240131-php-send-mail/ Share on other sites More sharing options...
fugix Posted June 22, 2011 Share Posted June 22, 2011 You will want to add another header. $headers .= 'From: [email protected]' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/240131-php-send-mail/#findComment-1233434 Share on other sites More sharing options...
hoponhiggo Posted June 22, 2011 Author Share Posted June 22, 2011 Thanks for the quick reply, Can I also ask, is this this code safe to use or is it vulnerable to "injections"? I'm still new to php so would be grateful for any advice Quote Link to comment https://forums.phpfreaks.com/topic/240131-php-send-mail/#findComment-1233448 Share on other sites More sharing options...
fugix Posted June 22, 2011 Share Posted June 22, 2011 I would filter user given emails using preg_match() preg_match('/^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/i') Quote Link to comment https://forums.phpfreaks.com/topic/240131-php-send-mail/#findComment-1233457 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.