Mason Posted September 15, 2007 Share Posted September 15, 2007 Hello. I have been trying to find out how to send an email message with variables passed through a URL all day... I have made many different mail forms and cannot get it to work. An example would be: http://www.testing.com/email.php/[email protected]&subject=testsubjecy&message=body of the message here Can any one help? Thank you! Link to comment https://forums.phpfreaks.com/topic/69484-send-email-with-url-variables/ Share on other sites More sharing options...
freakstyle Posted September 17, 2007 Share Posted September 17, 2007 Hi there, its not clear if you want to set variables in an html link that opens up the users email program, or if you want to send the email yourself. if you want to have a link for the user then the data on that link would need to be dynamic. consider this example: <?php $emailAddy = '[email protected]'; $Subject = 'hi mom'; $Body = 'i want you to see this'; ?> <a href="mailto:<?php echo $emailAddy; ?>?subject=<?php echo urlencode($Subject); ?>&body=<?php echo urlencode($Body); ?>Click here</a> if you want to have a contact form of sorts send out an email, then you would be better off creating your own script. see php.net for a breakdown: http://php.net/mail enjoy Link to comment https://forums.phpfreaks.com/topic/69484-send-email-with-url-variables/#findComment-350213 Share on other sites More sharing options...
Mason Posted September 18, 2007 Author Share Posted September 18, 2007 Thank you for your reply. I've since figured it out, and I'll post a condensed version of my script so that if someone else is searching this same subject, they can see a solution: <?php $message=$_GET['message']; mail([email protected]', 'Info', $message); ?> THANKS FOR SENDING! It's very simple. The variable is set to grab what is in the URL. Example: http://.../script.php/?message=mmmmmmeeeeesssagggeeehere!!!!!!!! Add as many variables as you'd like! Link to comment https://forums.phpfreaks.com/topic/69484-send-email-with-url-variables/#findComment-350711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.