Jump to content

Recommended Posts

I want to send a link through email using php.  I already have the email script written. I just need to know what is the line of code needed to send a link.  For example.  Here is what the body of the message looks like

$one = "Hello!.$bfn.\n\n Welcome to The Refiking";
$two = "\n\n When you login, you will be asked to change your password immediately.";
$three = "<a href="www.yahoo.com">Login Now</a>";
$message = $one . $two;

 

What do I need to change $three to?

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/
Share on other sites

Here's a script I wrote for sending html emails.

 

// Send HTML Email

	// This function is used for emailing a standardized form
	$headers = "From: $from \r\n";
	$headers .= "Cc: $cc \r\n";
	$headers .="Bcc: $bcc \r\n";
	$boundary = uniqid(md5(date("YmdHis"))); 
	$headers .= "Content-Type: multipart/alternative" .
  				"; boundary = $boundary\r\n\r\n"; 

	//message to people with clients who don't understand MIME
	$headers .= "This is a MIME encoded message.\r\n\r\n"; 

	//HTML version of message
	$headers .= "--$boundary\r\n" .
					   "Content-Type: text/html; charset=ISO-8859-1\r\n" .
					   "Content-Transfer-Encoding: base64\r\n\r\n";
	$headers .= chunk_split(base64_encode("$html")); 

	$mailSucceed = @mail($to, $subject, "", $headers);
	if($mailSucceed){
	    echo  "<p style=\"color: #336699; font-weight: bold;\">Mail Sent Successfully</p>";
	}else{
	    echo   "<p style=\"color: #336699; font-weight: bold;\">Mail Failed to Send</p>";
	}

 

This requires a $subject, $from, $to, $bcc, $cc, and $html variables before running.  The $html would be the html of the email being sent.

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428345
Share on other sites

<?php
$bfn = "Joe";
$user = 1;
$pass = 123;
$to = "johndoe@gmail.com";
$subject = "Test mail";
$one = "Hello $bfn!\n\n This is a verification email..";
$two = "\n\n When you login, you will be asked to change your password immediately.";
$three = <a href="www.yahoo.com">Login</a>;
$message = $one . $two . $three;
$from = "donotreply@refiking.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428652
Share on other sites

<?php
$bfn = "Joe";
$user = 1;
$pass = 123;
$to = "johndoe@gmail.com";
$subject = "Test mail";
$one = "Hello $bfn!\n\n This is a verification email..";
$two = "\n\n When you login, you will be asked to change your password immediately.";
$three = "<a href=\"www.yahoo.com\">Login</a>";
$message = $one . $two . $three;
$from = "donotreply@refiking.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

But note you must use the code I provided above in my previous posts to send this email as html, otherwise you'll see the <a href ... etc

 

If you don't care about sending it as an html email have $three look like this:

 

$three = "Login at www.yahoo.com";

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428658
Share on other sites

Replace your code with this:

 

// Send HTML Email

	// This function is used for emailing a standardized form
    $bfn = "Joe";
    $to = "johndoe@gmail.com";
    $cc = "";
    $bcc = "";
    $subject = "Test Mail";
    $one = "Hello $bfn!\n\n This is a verification email..";
	$two = "\n\n When you login, you will be asked to change your password immediately.";
	$three = "<a href=\"www.yahoo.com\">Login</a>";
	$message = $one . $two . $three;
	$from = "donotreply@refiking.com";
    
	$headers = "From: $from \r\n";
	$headers .= "Cc: $cc \r\n";
	$headers .="Bcc: $bcc \r\n";
	$boundary = uniqid(md5(date("YmdHis"))); 
	$headers .= "Content-Type: multipart/alternative" .
  				"; boundary = $boundary\r\n\r\n"; 

	//message to people with clients who don't understand MIME
	$headers .= "This is a MIME encoded message.\r\n\r\n"; 

	//HTML version of message
	$headers .= "--$boundary\r\n" .
					   "Content-Type: text/html; charset=ISO-8859-1\r\n" .
					   "Content-Transfer-Encoding: base64\r\n\r\n";
	$headers .= chunk_split(base64_encode("$html")); 

	$mailSucceed = @mail($to, $subject, "", $headers);
	if($mailSucceed){
	    echo  "<p style=\"color: #336699; font-weight: bold;\">Mail Sent Successfully</p>";
	}else{
	    echo   "<p style=\"color: #336699; font-weight: bold;\">Mail Failed to Send</p>";
	}

 

Let me know if it works

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428675
Share on other sites

Content-Type: text/html; charset=ISO-8859-1

 

Content-Transfer-Encoding: base64

 

 

 

SGVsbG8gSm9lIQoKIFRoaXMgaXMgYSB2ZXJpZmljYXRpb24gZW1haWwuLgoKIFdoZW4geW91IGxv

 

Z2luLCB5b3Ugd2lsbCBiZSBhc2tlZCB0byBjaGFuZ2UgeW91ciBwYXNzd29yZCBpbW1lZGlhdGVs

 

eS48YSBocmVmPSJ3d3cueWFob28uY29tIj5Mb2dpbjwvYT4=

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428706
Share on other sites

<?php

// Send HTML Email










// This function is used for emailing a standardized form
    $bfn = "Joe";
    $to = "user@refiking.com";
    $cc = "";
    $bcc = "";
    $subject = "Test Mail";
    $one = "Hello $bfn!\n\n This is a verification email..";





$two = "\n\n When you login, you will be asked to change your password immediately.";





$three = "<a href=\"www.yahoo.com\">Login</a>";





$html = $one . $two . $three;





$from = "donotreply@refiking.com";






$headers = "From: $from \r\n";





$headers .= "Cc: $cc \r\n";





$headers .="Bcc: $bcc \r\n";





$boundary = uniqid(md5(date("YmdHis")));





$headers .= "Content-Type: multipart/alternative" .










"; boundary = $boundary\r\n\r\n";












//message to people with clients who don't understand MIME





$headers .= "This is a MIME encoded message.\r\n\r\n";










//HTML version of message





$headers .= "--$boundary\r\n" .













   "Content-Type: text/html; charset=ISO-8859-1\r\n" .













   "Content-Transfer-Encoding: base64\r\n\r\n";





$headers .= chunk_split(base64_encode("$html"));












$mailSucceed = @mail($to, $subject, "", $headers);





if($mailSucceed){





    echo  "<p style=\"color: #336699; font-weight: bold;\">Mail Sent Successfully</p>";





}else{





    echo   "<p style=\"color: #336699; font-weight: bold;\">Mail Failed to Send</p>";





}

?>

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428713
Share on other sites

The following works for me, I just tested this script

 

Copy it exactly as it, changing only the email fields.

 

<?

// Send HTML Email

	// This function is used for emailing a standardized form
    $bfn = "Joe";
    $to = "joe@gmail.com";
    $from = "donotreply@refiking.com";
    $cc = "";
    $bcc = "";
    $subject = "Test Mail";
    $one = "Hello $bfn!\n\n This is a verification email..";
	$two = "\n\n When you login, you will be asked to change your password immediately.";
	$three = "<a href=\"www.yahoo.com\">Login</a>";
	$html = $one . $two . $three;
    
	$headers = "From: $from \r\n";
	$headers .= "Cc: $cc \r\n";
	$headers .="Bcc: $bcc \r\n";
	$boundary = uniqid(md5(date("YmdHis"))); 
	$headers .= "Content-Type: multipart/alternative" .
  				"; boundary = $boundary\r\n\r\n"; 

	//message to people with clients who don't understand MIME
	$headers .= "This is a MIME encoded message.\r\n\r\n"; 

	//HTML version of message
	$headers .= "--$boundary\r\n" .
					   "Content-Type: text/html; charset=ISO-8859-1\r\n" .
					   "Content-Transfer-Encoding: base64\r\n\r\n";
	$headers .= chunk_split(base64_encode("$html")); 

	$mailSucceed = @mail($to, $subject, "", $headers);
	if($mailSucceed){
	    echo  "<p style=\"color: #336699; font-weight: bold;\">Mail Sent Successfully</p>";
	}else{
	    echo   "<p style=\"color: #336699; font-weight: bold;\">Mail Failed to Send</p>";
	}
?>

 

This code should work, I just tested it.

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428722
Share on other sites

I copied it exactly and only changed the email field and this is what I got:

 

Content-Type: text/html; charset=ISO-8859-1

 

Content-Transfer-Encoding: base64

 

 

 

SGVsbG8gSm9lIQoKIFRoaXMgaXMgYSB2ZXJpZmljYXRpb24gZW1haWwuLgoKIFdoZW4geW91IGxv

 

Z2luLCB5b3Ugd2lsbCBiZSBhc2tlZCB0byBjaGFuZ2UgeW91ciBwYXNzd29yZCBpbW1lZGlhdGVs

 

eS48YSBocmVmPSJ3d3cueWFob28uY29tIj5Mb2dpbjwvYT4=

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/84144-email-link/#findComment-428725
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.