Jump to content

[SOLVED] link in email


mjgdunne

Recommended Posts

Hi, i have a php script where an email is sent to a specified email address. I am wondering how i can, or if i can place a link to a site in the email.

Here is my php code:

<?php

session_start();

ini_set( 'display_errors', '1' );
error_reporting ( 2047 );

$fromemail = "postmaster@localhost";
$scripturl = "http://localhost/xampp/mailsend.php";


$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="reff"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// image and titl and reg sent from form

$mymake=$_POST['mymake'];
$mymake=$_POST['mymodel'];
$myreg=$_POST['myreg'];
$myimage=$_POST['myimage'];


mysql_select_db("test");
$result = mysql_query("INSERT INTO reff (make, model, registration, imgdata)
  VALUES ('$_POST[mymake]', '$_POST[mymodel]', '$_POST[myreg]', '$_POST[myimage]')");



$to = "mjgdunne@hotmail.com";
$subject = 'You have being assigned a new case';
$message = 'Go to: http://localhost/rental.html' .  'You have being assigned a new case';

$headers = 'From: postmaster@localhost' . "\r\n" .
    'Reply-To: postmaster@localhost' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

header("location:case_assigned.php");


exit();
?>

Thanks  ???

Link to comment
Share on other sites

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

That will allow you to send HTML mail, then simply make your message:

$message = 'Go to: <a href="http://localhost/rental.html">http://localhost/rental.html</a>' .  'You have being assigned a new case';

Link to comment
Share on other sites

Hi, i have added your code, but the email is still not displaying the link correctly, im sending it to my hotmail account, maybe hotmail doesnt allow html emails?  ???

 

<?php

session_start();

ini_set( 'display_errors', '1' );
error_reporting ( 2047 );

$fromemail = "postmaster@localhost";
$scripturl = "http://localhost/xampp/mailsend.php";


$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="reff"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// image and titl and reg sent from form

$mymake=$_POST['mymake'];
$mymake=$_POST['mymodel'];
$myreg=$_POST['myreg'];
$myimage=$_POST['myimage'];


mysql_select_db("test");
$result = mysql_query("INSERT INTO reff (make, model, registration, imgdata)
  VALUES ('$_POST[mymake]', '$_POST[mymodel]', '$_POST[myreg]', '$_POST[myimage]')");



$to = "mjgdunne@hotmail.com";
$subject = 'You have being assigned a new case';

// 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";

$message = 'Go to: <a href="http://localhost/rental.html">http://localhost/rental.html</a>' .  'You have being assigned a new case';

$headers = 'From: postmaster@localhost' . "\r\n" .
    'Reply-To: postmaster@localhost' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

header("location:case_assigned.php");


exit();
?>

Link to comment
Share on other sites

You were overwriting your $headers variable and eraseing the content type

 

<?php
.....
// 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";

$message = 'Go to: <a href="http://localhost/rental.html">http://localhost/rental.html</a>' .  'You have being assigned a new case';

// You were overwriting the $header variable here.
// I changed the '=' to '.='
$headers .= 'From: postmaster@localhost' . "\r\n" .
    'Reply-To: postmaster@localhost' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

header("location:case_assigned.php");

.....

?>

Link to comment
Share on other sites

Hi i copied in ur code, maybe i did something wrong because it is now working:

<?php

session_start();

ini_set( 'display_errors', '1' );
error_reporting ( 2047 );

$fromemail = "postmaster@localhost";
$scripturl = "http://localhost/xampp/mailsend.php";


$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="reff"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// image and titl and reg sent from form

$mymake=$_POST['mymake'];
$mymake=$_POST['mymodel'];
$myreg=$_POST['myreg'];
$myimage=$_POST['myimage'];


mysql_select_db("test");
$result = mysql_query("INSERT INTO reff (make, model, registration, imgdata)
  VALUES ('$_POST[mymake]', '$_POST[mymodel]', '$_POST[myreg]', '$_POST[myimage]')");



$to = "mjgdunne@hotmail.com";
$subject = 'You have being assigned a new case';


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$message = 'Go to: <a href="http://localhost/rental.html">http://localhost/rental.html</a>' .  'You have being assigned a new case';


$headers = 'From: postmaster@localhost' . "\r\n" .
    'Reply-To: postmaster@localhost' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

header("location:case_assigned.php");


exit();
?>

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.