PHP autoresponder HTML - php

I have an auto responder hooked up to my form. When it is submitted I need toe person to get an email with a download link. Auto responder is working great but it is only seeing plain text so the link does not work properly. How can I get it to see HTML so it understands the hyperlink?
Thanks.
$header .= "Content-Type: text/html\r\n";
// Subject of confirmation email.
$conf_subject = 'Your Free Book';
// Who should the confirmation email be from?
$conf_sender = 'Your Book <no-reply#something.com>';
$msg = $_POST['Name'] . ",\n\nThank you for interest in our book. To Download Click Here";
mail( $_POST['Email'], $conf_subject, $msg, 'From: ' . $conf_sender );
}

Related

adding a hyperlink in a sms email

What I am trying to do is send a registration confirmation sms via email from my website. I have it working now but I want to make sure that people are putting in correct phone numbers and carrier data. When my message sends it will send the word link but its not clickable is there a way to make the link clickable?
Here is my code so far.
<?php
$to = $mobil.$carier;
$subject = 'Registration for'.$school .'Scholarships Page';
$message = "
<html>
<head>
<title>Registration Email</title>
</head>
<body>
<h1>Email Registration Confirmation</h1>
<p>Welcome".$first_name." ". $last_name."
<p>In order to finish your registration for the scholarship site you need a valid
text phone number.
<p>Please Click the link given to confirm your registration.</p>
<a href=\"http://scholarship_domain/scholarships/activate.php?id=".$active_mobil ."\">Link
</a>
<p>If you have problems please contact your counsellor at your school. </p>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <scholarships.gnspes.ca>' . "\r\n";
mail($to,$subject,$message,$headers);
?>
What happens now is the message sends but the link is not clickable and only the words "link" show up in the message. I guess I could just make it a link that a person could copy and paste but I am wondering if there is a way to make it a true hyperlink?
Thanks for the help.
When sending an Email or SMS to a phone number the message is automatically changed into html on the phone. I was able to get a clickable link send to myself with the following code but I would suggest making the message that it sends a little bit shorter because this message has to be sent as a picture message. I sent it to myself using just 0000000000#vtevt.com and it worked but the message was too long to show all the info so I sent just the link part and it works.
<?php
$to = $mobil.$carier;
$subject = 'Registration for '.$school .' Scholarships Page';
$message = '
Email Registration Confirmation
Welcome '.$first_name.' '. $last_name.'
In order to finish your registration for the scholarship site you need a valid
text phone number.
Please Click the link given to confirm your registration.
http://scholarship_domain/scholarships/activate.php?id='.$active_mobil .'
If you have problems please contact your counsellor at your school.
';
$message = str_replace("\n.", "\n..", $message);
// Always set content-type when sending HTML email
//$headers = "MIME-Version: 1.0" . "\r\n";
//$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
//$headers .= 'From: <scholarships.gnspes.ca>' . "\r\n";
mail($to,$subject,$message);
?>
Also there is no need to send headers in a text message if that's where your sending it to. And the subject doesn't work in a text. It only shows the email or website that it was send from.

PHP Send a mail to user mail address entered into a text box

I am trying to make a simple form that sends the user defined/entered email address a link to them.
Visitor > Enter Mail > Hit Send > Receives a mail with a link
But I am battling to make it work.
$headers = "From: Siddharth Jain <email>\r\n";
$headers .= "Reply-To: Siddharth Jain <email>\r\n";
$headers .= "Return-Path: email\r\n";
$headers .= "Bcc: Siddharth Jain <email>\r\n";
$headers .= "PHP/" . phpversion();
$to = $_REQUEST['email'];
$subject="";
$mailcontent='Codeword: '.$_POST["text_box"];
mail($to, $subject, $mailcontent, $headers);
Replace "email" with your email and "Siddharth Jain" with the name you need to display in that email.
thanks Mitali Mehta :)
Got this to work.
<?php
// Contact subject
$subject ="mail subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="no-reply#domain.com";
// From
$header="from: no-reply#domain.com";
// Enter your email address
$to = $_REQUEST['customer_mail'];
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
header("Location:http://www.domain.com/");
}
else {
echo "ERROR";
}
?>
in case someone else wants it :)
also this sends me a copy of the request too.

php email script for just email address

Im new to this PHP stuff so please excuse my ignorance
Im after having just one input text box in my flash website where a person just enters there email address and at the click of a button it sends an email to me to a pre defined email address with a predefined subject heading and the email address that was entered in the body of the email
Anyone know of any links or can give some help
all the ones i have found want names email subject message and so on
Any help is appreciated
Mark
EDIT
ok I have the following
In flash I have an input text converted to a movieclip called "addy". Inside the movie clip which has the inputbox which has the variable name "emailaddy"
A Button called "email"
The code i Have running when "email" is clicked is
on (release) {
form.loadVariables("email.php", "POST");
}
the email.php script is as follows
<?php
$sendTo = "mark#here.co.uk";
$subject = "Subscribe to Website";
$headers = "From: Website";
$headers .= "<" . $_POST["addy"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["addy"] . "\r\n";
$headers .= "Return-Path: " . $_POST["addy"];
$message = "Please Subscribe me to Website";
mail(recipient, subject, message, other headers);
mail($sendTo, $subject, $message, $headers);
?>
when I click the button nothing happens
what im after is when the button is clicked for and email to be sent in the following format
To: "mark#here.co.uk"
From: email address specified in text field "addy"
Subject: "Subscribe to Website";
body: "Please subscribe me to Website"
Your help is greatly appreciated
mark
The following code might help:
<?php
$user_mail=$_POST["mail"]; //or $user_mail=$_GET["mail"]; Set to your convenience!
$to_mail="abcde#xyz.com"; //Change to your email address
$message="New user's Email: ".$user_mail; //Change to your requirements
$subject="New user registered"; //Change to your preferred subject
$from="registration#yourwebsite.com"; //Change to your website mail id
mail($to_mail,$subject,$message,"From: $from\n");
To know more about the mail function, please see the documentation.
Well in depth you can do like this
<?php
if($_POST){
$userEmail = $_POST0["emailaddy"]; // textbox variable name comes here
$to = 'abc#xyz.com'; //write down here your email
$subject = 'Subscribe to website'; // your subject goes here
$message = 'Please Subscribe me to Website'; // Mail body message
$headers = 'From: ' . $userEmail . "\r\n" .
'Reply-To: ' . $userEmail . "\r\n" .
'Return-Path: ' . $userEmail; //can send x-Mailer also
mail($to, $subject, $message, $headers);
}else{
echo "Invalid Request";
return false;
}
Don't forget to check first $_POST is happened or not. No need to send Return-path instead of this use x-Mailer which sound good for other mail service providers.
To know more about this read documentation here.
If you want to connect to an SMTP server ,like Postfix or gmail there is a neat php library called PhpMailer.
It is well documentated, so you should be good to go by googleing it :)

PHP email() function not sending message correct?

I'm at the final part of my code, the email verification. However, the email don't seem to be sent correctly. For the sake of spam, I'll replace my email with _EMAIL_.
$hash = genRandomString();
$link = 'http://www.website.com/verify.php?email=' . $email . '&hash=' . $hash;
$message = 'Please confirm your email address by click this following link, or copy and pasting it into your web browser.'
. $link;
mail($email, 'Account verification for website.com', $message);
All the data is going correctly into the database (No incorrect variables), but the email comes though something like this:
Please confirm your email address by click this following link, or copy and pasting it into your web browser.
_EMAIL_&hash=0uhcoawgi3qsek8l7rjoheo'>http://www.website.com/verify.php?email=_EMAIL_&hash=0uhcoawgi3qsek8l7rjoheo
I'm assuming this is something I'm doing wrong, but I can't spot it after various pieces of troubleshooting.
By default, mail sends plain text emails. If you want to send HTML emails, you have to add the appropriate header to the message. Keep in mind that not all email clients support HTML mail, and some people disable it.
With that said, if you still want to send HTML mail (lots of people do), here's how:
mail($To, $Subject, $Message, 'Content-type: text/html');
You also seem to have some issues with your message string. HTML links look like this:
link-text
So, try making your message string something like this:
$message = 'Please confirm your email address by click this following link, or copy and pasting it into your web browser. Activation Link';
Where's your PHP mail content-type? To send HTML mail, the Content-type header must be set.
<?php
// message
$hash = genRandomString();
$link = 'http://www.website.com/verify.php?email=' . $email . '&hash=' . $hash;
$message = 'Please confirm your email address by click this following link.'
. $link;
// 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 it
mail($email, 'Account verification for website.com', $message, $headers);
?>
That's it. Send it again and everything should be hyperlinked.

Change email address that sends confirmation email (PHP)

I have a registration page on a site I'm working on. When the person registers for an account it sends an email to the registrants email address with a confirmation link to activate the persons account. The problem is that the "from" email address the registrant receives the email from is: myhostingaccountusername#myhostingprovider###.com.
I want to be able to have the email be: no-reply#mydomain.com.
I'm using PHP and Mysql along with html for the site.
here is my code for sending the email.
// Send the email:
$body = "Thank you for registering at My site. To activate your account, please click on this link:\n\n";
$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$abc";
mail($trimmed['email'], 'Registration Confirmation', $body, 'From: noreply#mysite.com');
How do I do this?
When sending the e-mail to your "registrant" you should set the headers of the mail function in PHP to contain "From" field
for example :
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: no-reply#example.com' . "\r\n" .
'Reply-To: me#example.com' . "\r\n";
mail($to, $subject, $message, $headers);
?>
Have you set the From: header for the e-mail?
See http://php.net/manual/en/function.mail.php, example #2.

Categories