Forum Moderators: coopster

Message Too Old, No Replies

Mailform email message not showing links

         

Jeztechs

6:48 am on Aug 13, 2005 (gmt 0)

10+ Year Member



Hi all,

Please, please can someone help me.
I have been using the simple mailform script below for many clients as well for my own business site for over a year now. I now have a client who sais when they receive the form results in their Outlook inbox...the recipients email is not hyperlinked (so they can just click on the address to reply).......but why is it that when I test it to come into my own Outlook Express inbox all hyperlinks are showing and formated perfectly? I have only noticed the client was right after installing Outlook myself last night....no hyperlinks showing and formating all messed up.

Is there a simple way I can have the hyperlinks showing in Outlook?

The script was given to me as I am learning as I go.

Many thanks in advance.
Jeremy

<?
$to = "bookings@somewhere.com.au";

// 'contact' is the name of the Submit button on the form
if(isset($_POST['Contact']))

$name = $_POST['name'];
$email = $_POST['email'];
$town = $_POST['town'];
$country = $_POST['country'];
$enquiry = $_POST['enquiry'];
// done -- Now the variables can be sent in the email

// Create the email subject here
$subject = "Somewhere Enquiry Form Submission";
// Create the email message

$message = "$name has submitted the Somewhere Enquiry Form\r\n";
// the .= appends extra lines the the $message variable to make reading the script easier
$message .= "Their details are as follows:\r\n\r\n";
$message .= "Email Address: $email\r\n";
$message .= "Town/City: $town\r\n";
$message .= "Country: $country\r\n";
$message .= "Enquiry: $enquiry\r\n";

$thankyouPage = "index.php";

$tipsMessage = "Hi " . $name . "\r\n\r\n";
$tipsMessage .= "Many thanks for your enquiry to Somewhere\r\n\r\n";
$tipsMessage .= "I will contact you within the next 48 hours\r\n\r\n";
$tipsMessage .= "Regards\r\n";
$tipsMessage .= "Mr Somewhere\r\n\r\n";
$tipsMessage .= "www.Somewhere.com.au";
// send the newsletter link to the visitor
mail($email, "Somewhere Enquiry Form", $tipsMessage, "From: bookings@Somewhere.com.au<bookings@Somewhere.com.au>");
}

mail($to, $subject, $message, "From: $name<$EmailAddress>");
header("Location: $thankyouPage");
?>

dreamcatcher

6:55 am on Aug 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jeztechs, welcome to Webmaster World. :)

Instead of:

$tipsMessage .= "www.Somewhere.com.au";

try:

$tipsMessage .= "http://www.Somewhere.com.au";

dc

Jeztechs

7:19 am on Aug 13, 2005 (gmt 0)

10+ Year Member



Thanks for that Dreamcatcher...but I think I should have mentioned the http address is fine (shows hyperlinks)....its the recipients email address that does not show the underline (not hyperlinked) in outlook...any ideas?

Boy I need a lifeline as I have a few clients that have big forms which I have always assumed are working well as I only have been testing them in Outlook Express which DO underline the recipients email address!

Many thanks
Jeremy

dreamcatcher

11:59 am on Aug 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to think about using HTML headers and use standard HTML in the message body.

dc

Jeztechs

1:26 pm on Aug 13, 2005 (gmt 0)

10+ Year Member



Hey DC,

I think I am lost because of my slow learning curve.....dont suppose you can put the headers in on the example script I have posted as i dont really understand....no worries if it is too much work...

Many thanks
Jeremy

dreamcatcher

6:26 pm on Aug 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jeremy,

Its no problem. Here is a little function I use:


function mail_headers($name,$email)
{
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name<" . $email . ">\n";
$headers .= "X-Sender: $name<" . $email . ">\n";
$headers .= "X-Mailer: PHP " . phpversion() . "\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-Sender-IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
$headers .= "Return-Path: $name<" . $email . ">\n";
$headers .= "Reply-To: $name<" . $email . ">\n";

return $headers;

}

Note the first line. This is needed for HTML e-mails.

This is an example of using the function with one of your mail function lines:

Before:

mail($to, $subject, $message, "From: $name<$EmailAddress>");

After:

mail($to, $subject, $message, mail_headers($name,$EmailAddress));

Thats it. In your message you can now use HTML.

Hope that works for you.

dc

Jeztechs

12:33 am on Aug 14, 2005 (gmt 0)

10+ Year Member



Hi Dc,

Thanks so much for helping here...but I am afraid i cannot grasp things at all. I dont suppose you can add the code you gave me to the script I first posted so i know where it all is supposed to go. Then hopefully from there I can just copy the whole corrected script and learn from there.

Again..i know i am asking a lot, so only if you have time mate.

Thanks so much
Jeremy

dreamcatcher

12:26 pm on Aug 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem, try this:


<?

function mail_headers($name,$email)
{
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name<" . $email . ">\n";
$headers .= "X-Sender: $name<" . $email . ">\n";
$headers .= "X-Mailer: PHP " . phpversion() . "\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-Sender-IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
$headers .= "Return-Path: $name<" . $email . ">\n";
$headers .= "Reply-To: $name<" . $email . ">\n";

return $headers;

}

$to = "bookings@somewhere.com.au";

// 'contact' is the name of the Submit button on the form
if(isset($_POST['Contact']))

$name = $_POST['name'];
$email = $_POST['email'];
$town = $_POST['town'];
$country = $_POST['country'];
$enquiry = $_POST['enquiry'];
// done -- Now the variables can be sent in the email

// Create the email subject here
$subject = "Somewhere Enquiry Form Submission";
// Create the email message

$message = "$name has submitted the Somewhere Enquiry Form<br><br>\n";
// the .= appends extra lines the the $message variable to make reading the script easier
$message .= "Their details are as follows:<br><br>\n";
$message .= "Email Address: $email<br>\n";
$message .= "Town/City: $town<br>\n";
$message .= "Country: $country<br>\n";
$message .= "Enquiry: $enquiry<br>\n";

$thankyouPage = "index.php";

$tipsMessage = "Hi " . $name . "<br><br>\n";
$tipsMessage .= "Many thanks for your enquiry to Somewhere<br><br>\n";
$tipsMessage .= "I will contact you within the next 48 hours<br><br>\n";
$tipsMessage .= "Regards<br>\n";
$tipsMessage .= "Mr Somewhere<br><br>\n";
$tipsMessage .= "www.Somewhere.com.au";
// send the newsletter link to the visitor
mail($email, "Somewhere Enquiry Form", $tipsMessage, mail_headers('bookings@Somewhere.com.au','bookings@Somewhere.com.au'));
}

mail($to, $subject, $message, mail_headers($name,$EmailAddress));
header("Location: $thankyouPage");
?>

Give that a try.

dc

Jeztechs

5:28 am on Aug 15, 2005 (gmt 0)

10+ Year Member



Hi Dc,

Thanks once more but it did not work..the email address is still not hyperlink, (as well as any links the mailform generates now).

Just wondered how you get around this one for your own clients running on outlook.

Regards
Jeremy

dreamcatcher

8:09 am on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jeremy,

You need to use HTML code. What I posted was an example.

Change:

$message .= "Email Address: $email<br>\n";

to:

$message .= "Email Address: <a href=\"mailto:$email\">$email</a><br>\n";

dc

Jeztechs

1:07 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



Hey Dc....your a star...it worked :)

Just wondered if you could really polish the script off by helping with the following...i have tried for ages but cannot understand something that i am sure you will find simple:

The email message 'from' heading is blank..can this be easely sorted?

Now the recients email is hyperlinked....how do i hyperlink the web address i have in the script (auto responder one...www.Somewhere.com.au)?

This aint a big problem but is there a way the following can be set so it does not show up on the email:
From: Jeremy <> X-Sender: Jeremy<> X-Mailer: PHP 4.3.2 X-Priority: 3 X-Sender-IP: 211.27.129.149 Reply-To: Jeremy <> X-Antivirus: AVG for E-mail 7.0.338 [267.10.9]

If you ever find your way in Queensland, Australia I will buy you a beer or 2 or 3 :)

thanks so much...Jeremy

dreamcatcher

7:34 pm on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you see the cricket today? Great stuff.

Anyway, for the URL again use HTML:

Change:
$tipsMessage .= "www.Somewhere.com.au";

to:
$tipsMessage .= "<a href=\"http://www.Somewhere.com.au\">www.Somewhere.com.au</a>";

To change the header data remove the lines from the mail_headers function.

As for the 'For', try using a name instead of an e-mail address in your mail function. ie:

mail_headers('Your Website','bookings@Somewhere.com.au'));

dc

Jeztechs

12:20 am on Aug 16, 2005 (gmt 0)

10+ Year Member



Hi DC...nope, not into cricket...still into watching West Ham FC :)

OK..this has got to be the last time I bug you....here is the script so far:

<?
function mail_headers($name,$email)
{
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name<" . $email . ">\n";
return $headers;

}

$to = "info@example.com";

// 'contact' is the name of the Submit button on the form
if(isset($_POST['Contact']))

$name = $_POST['name'];
$email = $_POST['email'];
$town = $_POST['town'];
$country = $_POST['country'];
$enquiry = $_POST['enquiry'];
// done -- Now the variables can be sent in the email

// Create the email subject here
$subject = "Moreton Island Accommodation Enquiry Form Submission";
// Create the email message

$message = "<br><br>$name has submitted the Moreton Island Accommodation Enquiry Form Submission<br>\n";
// the .= appends extra lines the the $message variable to make reading the script easier
$message .= "Their details are as follows:<br><br>\n";

$message .= "Email Address: <a href=\"mailto:$email\">$email</a><br>\n";
$message .= "Town/City: $town<br>\n";
$message .= "Country: $country<br>\n";
$message .= "Enquiry: $enquiry<br>\n";

$thankyouPage = "index.php";

$tipsMessage = "<br><br>Hi " . $name . "<br><br>\n";
$tipsMessage .= "Many thanks for your enquiry to Moreton Island Accommodation<br><br>\n";
$tipsMessage .= "I will contact you within the next 48 hours<br><br>\n";
$tipsMessage .= "Regards<br>\n";
$tipsMessage .= "Russell Densley<br><br>\n";
$tipsMessage .= "<a href=\"http://www.Somewhere.com.au\">www.Somewhere.com.au</a>";
// send the newsletter link to the visitor
mail($email, "Somewhere Enquiry Form", $tipsMessage, mail_headers('bookings@example.com.au','bookings@example.com.au'));
mail($to, $subject, $message, mail_headers($name,$EmailAddress));
header("Location: $thankyouPage");
?>

I have tried everything you suggested to get the 'From' heading to show up on the email heading (status bar)when it come into Outlook...its still blank...it shows up on the actual message when opened.

Any chance of adjusting the code above :)

I am almost there and could have not got this far without your help...thankyou

Jeremy

[edited by: coopster at 12:43 am (utc) on Aug. 16, 2005]
[edit reason] generalized email addresses [/edit]