Jump to content

Send Email With URL Variables?


Mason

Recommended Posts

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/?mailto=test@test.com&subject=testsubjecy&message=body of the message here

 

Can any one help?

 

 

Thank you!

Link to comment
Share on other sites

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 = 'mom@yourdomain.noo';
$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
Share on other sites

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(youremail@address.com', '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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.