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/[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

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

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!

Archived

This topic is now archived and is closed to further replies.

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