[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


PHP Send Predefined Email on a href link

Posted on 2007-10-12
Medium Priority
Last Modified: 2012-05-05
I  want to send this email to the user when they click on the link, "Click here for instructions"
Here is my code.
$to = $user->email;
$headers = "From: mysite.com <info@mysite.com>\r\n".
       "Reply-To: donotreply@mysite.com\r\n".
       "X-Mailer: PHP/" . phpversion();
$subject = "ZipPass Setup Instructions";
$body = "            
1. Wash
2. Rinse
3. Repeat
mail($to, $subject, $body, $headers))

Question by:terrysv1
  • 3
  • 2
LVL 17

Expert Comment

ID: 20067027
What isn't working?

You didn't describe what the problem is.
LVL 17

Expert Comment

ID: 20067036
I would use phpmailer


Author Comment

ID: 20067067
I Need to know the exact code for the php page on how to make the link when clicked sends that email
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 54

Accepted Solution

b0lsc0tt earned 500 total points
ID: 20067094

Where is the script above in relation to the page with the link (i.e. same page, different php page)?  Do you expect the page to change (i.e. reload, go to success page, etc) when the link is clicked or do you want nothing to happen to the page with the link.

The link is in the browser but the script is server side.  For it to run the page needs to go back to the server or you would have to use an effect called AJAX.  The easiest is to let the link go to the php script so it can run.  Then the server script will either reload the page or send a "success" page to the browser.  In this case you just need a link like ...

<a href="mailscript.php">Click here for instructions</a>

If this has to happen with no page reload then you use Javascript and the xmlhttp object to "run" the php script while the page is still in the browser.  You can even have the php script return some result and use Javascript and the DOM to change the html page and show the result.  This effect is called AJAX.  Let me know if you need more info on it.

Let me know if you have any questions or need more information.

LVL 17

Expert Comment

ID: 20067121
at the end of the mailscript.php you will need to add
so that after it sends the mail it will redirect back to the page where it was clicked from.
LVL 54

Expert Comment

ID: 20067358
I'm glad I could help.  Thanks for the grade, the points and the fun question.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question