Email Scripts

  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 7:32 am

I have created a nice simple email script
but 2 questions

1) How do I get this to send in HTML format (if it can be done)
2) If I can do Q1, can I include hyperlinks in the normal way

Code: [ Select ]
$to="domain@domain.com,$emailAddress";
                                $subject = "New IT Request - Call Reference $callReference";

$message = "Hello $sesslogin, you have just submitted a request to IT Support.\n
This email is confirmation of that action and should be kept as such until you are notified that the request has been closed
                                    
You reported the problem:
$requestDetails";
                                    
                                    
if(mail($to,$subject,$message))
                                {
    echo "Your should have now received a copy of this email, providing your email address was input correctly.\n\n";
                                }
                                else

        {
                                echo "There was a problem sending the mail. Please check that you filled in the form correctly.\n
                                If you believe you have filled it in correctly, there may be a problem contacting the email\n server. Please try again later";
    }
  1. $to="domain@domain.com,$emailAddress";
  2.                                 $subject = "New IT Request - Call Reference $callReference";
  3. $message = "Hello $sesslogin, you have just submitted a request to IT Support.\n
  4. This email is confirmation of that action and should be kept as such until you are notified that the request has been closed
  5.                                     
  6. You reported the problem:
  7. $requestDetails";
  8.                                     
  9.                                     
  10. if(mail($to,$subject,$message))
  11.                                 {
  12.     echo "Your should have now received a copy of this email, providing your email address was input correctly.\n\n";
  13.                                 }
  14.                                 else
  15.         {
  16.                                 echo "There was a problem sending the mail. Please check that you filled in the form correctly.\n
  17.                                 If you believe you have filled it in correctly, there may be a problem contacting the email\n server. Please try again later";
  18.     }
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 20th, 2004, 7:32 am

  • Cafu
  • Student
  • Student
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 97
  • Status: Offline

Post July 20th, 2004, 8:56 am

Something like this works for me:

Code: [ Select ]
$email = "to@emailaddress.com";
$headers = "From: Webform <from@emailaddress.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$subject = "This is an email yo";
$message = "blah blah blah";

mail($email, $subject, $message, $headers);
  1. $email = "to@emailaddress.com";
  2. $headers = "From: Webform <from@emailaddress.com>\r\n";
  3. $headers .= "MIME-Version: 1.0\r\n";
  4. $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  5. $subject = "This is an email yo";
  6. $message = "blah blah blah";
  7. mail($email, $subject, $message, $headers);



not sure on hyperlinks... play around with it.
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 8:57 am

Champion, I'll take that and give it a go

Thanks
  • datona
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 18, 2004
  • Posts: 8
  • Loc: Canada
  • Status: Offline

Post July 20th, 2004, 10:53 am

Cafu's code is correct. I have added a bit JUST to give you an idea as to how to put in hyperlinks:

Code: [ Select ]
$email = "to@emailaddress.com";
$headers = "From: Webform <from@emailaddress.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$subject = "This is an email yo";

$message = "<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#0000FF\" VLINK=\"#800080\">
This is a link to <a href=\"http://www.yahoo.com\">Yahoo.com</a>
</BODY>
</HTML>
";

mail($email, $subject, $message, $headers);
  1. $email = "to@emailaddress.com";
  2. $headers = "From: Webform <from@emailaddress.com>\r\n";
  3. $headers .= "MIME-Version: 1.0\r\n";
  4. $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  5. $subject = "This is an email yo";
  6. $message = "<HTML>
  7. <HEAD>
  8. <TITLE></TITLE>
  9. </HEAD>
  10. <BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#0000FF\" VLINK=\"#800080\">
  11. This is a link to <a href=\"http://www.yahoo.com\">Yahoo.com</a>
  12. </BODY>
  13. </HTML>
  14. ";
  15. mail($email, $subject, $message, $headers);


This should work for you fine.
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 11:11 am

also great, will apply asap

can I just ask what the \r entry is for
i know what \n and \t are for, but not \r
  • Cafu
  • Student
  • Student
  • No Avatar
  • Joined: Jul 15, 2004
  • Posts: 97
  • Status: Offline

Post July 20th, 2004, 11:24 am

beats the hell out of me, I just copied that from somewhere and it worked :twisted:


But, I can look it up! from

http://us3.php.net/types.string


\n = linefeed (LF or 0x0A (10) in ASCII)
\r = carriage return (CR or 0x0D (13) in ASCII)

So, if I had to guess I'd say they put both line feed and carriage return because different mail servers recognize different ones. Perhaps its so the code will work correctly with both *nix and windows mail servers.
  • tommya
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Mar 17, 2004
  • Posts: 221
  • Loc: United Kingdom
  • Status: Offline

Post July 20th, 2004, 11:26 am

makes sense

i've just tried the code that you guys give me and its worked a treat, cheers
  • datona
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jul 18, 2004
  • Posts: 8
  • Loc: Canada
  • Status: Offline

Post July 20th, 2004, 11:42 am

Tommya,

Glad you got it working!

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 162 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.