Jump to content

Cannot display a link or image with absolute url in autoresponder


Recommended Posts

I am trying to make an autoresponse display an image that can be clicked on to take the recipient back to the site where they filled out the contact form. here is the code:

[code]<?php
$subject="You just received an email from www.yoursite.com : Contact Form";
$recepient ="admin@yoursite.com";
$body = "<br><strong>First Name:</strong> ".$_REQUEST['first_name']."<br><strong>Last Name:</strong> ".$_REQUEST['last_name']."<br><strong>Email:</strong> ".$_REQUEST['email']."<br><strong>Address:</strong> ".$_REQUEST['addr1']."<br><strong>Apt/Suite/Box:</strong> ".$_REQUEST['apt_suite']."<br><strong>City:</strong> ".$_REQUEST['city']."<br><strong>State:</strong> ".$_REQUEST['state']."<br><strong>Zip Code:</strong> ".$_REQUEST['zip']."<br><strong>Country:</strong> ".$_REQUEST['country']."<br><strong>Telephone:</strong> ".$_REQUEST['phone']."<br><strong>Email:</strong> ".$_REQUEST['email']."<br><strong>Residence Type:</strong> ".$_REQUEST['residence_type']."<br><strong>Price Range:</strong> ".$_REQUEST['price_range']."<br><strong>Where Did You Hear About Us?:</strong> ".$_REQUEST['heard_about'];
$email = $_REQUEST['email'];
ini_set("SMTP","mail.yoursite.com"); 
ini_set("smtp_port","25"); 
ini_set("sendmail_from","contact@yoursite.com"); 
mail($recepient,$subject,$body,"FROM: $email\nContent-Type: text/html");
$subject="Thank you for your interest in www.yoursite.com : Contact Form";
$body = <<<EOF <html><body><br>Thank you for your submission!<br>
<br>Click on the image below for your confirmation!<br>
<br><a href="http://www.yoursite.com/thankyou.html"><img src="http://www.yoursite.com/thanks.jpg" alt="Thanks!" width="244" height="165"></a><br></body>
</html> EOF;
ini_set("SMTP","mail.yoursite.com"); 
ini_set("smtp_port","25"); 
ini_set("sendmail_from","contact@yoursite.com"); 
mail($email,$subject,$body,"FROM: contact@yoursite.com\nContent-Type: text/html");
echo("<META HTTP-EQUIV='Refresh' CONTENT='0;URL=http://www.yoursite.com'>");
?> [/code]

Anyone have any suggestions? I am dead in the water and would be extremely grateful for any feedback...
The top part of the code sends a notification to the admin with the form data

The second part sends an acknowledgement email to the sender of the form.

It is not specific to any email program, when I made the second part just text without any URLs, it worked fine.
When I attempted to make it HTML with an image linked to it it does not work.

Am I explaining this properly? Thanks for your response!
Yes, that's helpful :)  Just a few more questions - how doesn't it work?  Does the image appear, but nothing happens when you click on it?  Or is there no image appearing?  And in which email program does it not work?  The program you are testing with is relevant to diagnosing the problem.

Or does the email simply not get sent?  Or not arrive?  Spam filters can sometimes cause non-arrival even when an email is being sent.

Your html looks ok.. an img inside an "a href" should make a clickable image.
ok - here is the problem - it never gets sent, it never gets to the REFRESH stage (second line from the bottom)
If I do all this as plain text it works fine.

I am checking the emails in Outlook 2003 for windows and Entourage 2004 for Mac. It has worked... it is just when I insert the HTML code that it chokes.  >:(
I checked the syntax, and I think you need to change to this:

[code]$body = <<<EOF
<html><body><br>Thank you for your submission!<br>
<br>Click on the image below for your confirmation!<br>
<br><a href="http://www.yoursite.com/thankyou.html"><img src="http://www.yoursite.com/thanks.jpg" alt="Thanks!" width="244" height="165"></a><br></body>
</html>
EOF;[/code]

The final EOF must be at the start of a line, and the beginning EOF syntax is not exactly like some other languages (perl I think allows more flexibility with the starting marker)

Btw, knowing that the email was never sent and that the meta refresh doesn't display is why I knew to look at the syntax first.. otherwise I would have no idea where to start debugging.  Which is why I asked all those questions :)
Does "hangs up on the HTML" means it doesn't send the email and doesn't display any errors?

If so, you probably have another syntax error in there.

Are you able to use a shell to check the syntax of your script?

If not, can you set the display_errors configuration variable to true?  Then any syntax errors will be shown in the browser.

If there's no syntax errors, then add print statements throughout your script to see how far it gets before dying.
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.