russia5 Posted September 10, 2006 Share Posted September 10, 2006 Hello. I am trying to install an HTML email script. I have found this same coding in two places including Zend Codex. I get White space on both of them. Can somebody tell me why? Am I suppose to call this script to someplace else or something? Thanks to all that try to help me![code]<?php $to = "johndoe@fakedomain.com"; $from = "janedoe@anotherfakedomain.com"; $subject = "This is a test email"; $message = <<<EOF <html> <body bgcolor="#ffffff"> <p align="center"> <b>Hello World!</b> </p> </body> </html> EOF; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($to, $subject, $message, $headers); if ($success) echo "The email to $to from $from was successfully sent"; else echo "An error occurred when sending the email to $to from $from"; ?> [/code]ie) when I call this page www.mysite.com/thispage.php I get only white space. I believe I should be getting some sort of text box to put my HTML email in. Thanks again... Greg Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/ Share on other sites More sharing options...
HuggieBear Posted September 10, 2006 Share Posted September 10, 2006 No, you shouldn't be getting a form, you should be getting one of two messages...1. The email to johndoe@fakedomain.com from janedoe@anotherfakedomain.com was successfully sentor2. An error occurred when sending the email to johndoe@fakedomain.com from janedoe@anotherfakedomain.comRegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89501 Share on other sites More sharing options...
ronverdonk Posted September 10, 2006 Share Posted September 10, 2006 Works for me! I only removed the extraneous blanks after <<<EOF and after EOF;Ronald 8) Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89504 Share on other sites More sharing options...
HuggieBear Posted September 10, 2006 Share Posted September 10, 2006 Me too, but I had to tidy up the if statement too...[code]<?php $to = "myemail@hotmail.co.uk"; $from = "janedoe@anotherfakedomain.com"; $subject = "This is a test email"; $message = <<<EOF<html> <body bgcolor="#ffffff"> <p align="center"> <b>Hello World!</b> </p> </body> </html> EOF; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($to, $subject, $message, $headers); if ($success) { echo "The email to $to from $from was successfully sent"; } else { echo "An error occurred when sending the email to $to from $from"; }?>[/code]RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89505 Share on other sites More sharing options...
ronverdonk Posted September 10, 2006 Share Posted September 10, 2006 Your original IF statement was fine, why'd you change it. Not that it is wrong now ...Ronald 8) Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89516 Share on other sites More sharing options...
HuggieBear Posted September 10, 2006 Share Posted September 10, 2006 I got a parse error when I ran it. I corrected the spaces after <<<EOF and EOF at the same time I fixed the IF statement, so I didn't know which had fixed it. I didn't realise you didn't need the curley braces when coding an IF statement.Learn something new everyday.Rich Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89518 Share on other sites More sharing options...
maxic0 Posted September 10, 2006 Share Posted September 10, 2006 Can someone explain to me what <<<EOF is please?I googled it but i didn't understand anything that came up. Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89522 Share on other sites More sharing options...
ronverdonk Posted September 10, 2006 Share Posted September 10, 2006 It is a so called heredoc statement. I'll quote from the PHP documentation:[quote]Another way to delimit strings is by using heredoc syntax ("<<<"). One should provide an identifier after <<<, then the string, and then the same identifier to close the quotation. The closing identifier must begin in the first column of the line. Also, the identifier used must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore. [/quote]See [url=http://nl3.php.net/manual/en/language.types.string.php]http://nl3.php.net/manual/en/language.types.string.php[/url]for more detailed info.Ronald 8) Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89531 Share on other sites More sharing options...
ronverdonk Posted September 10, 2006 Share Posted September 10, 2006 [quote author=HuggieBear link=topic=107573.msg431788#msg431788 date=1157920372]I got a parse error when I ran it. I corrected the spaces after <<<EOF and EOF at the same time I fixed the IF statement, so I didn't know which had fixed it. I didn't realise you didn't need the curley braces when coding an IF statement.Learn something new everyday.Rich[/quote]Huggybear : you don't need to enclose the IF or ELSE action between curly braces if and only if it is a single statement. Also goes for some other statements such as FOR, etc.Ronald 8) Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89532 Share on other sites More sharing options...
HuggieBear Posted September 10, 2006 Share Posted September 10, 2006 Thanks Ronald, I'll bear that in mind.RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89536 Share on other sites More sharing options...
russia5 Posted September 11, 2006 Author Share Posted September 11, 2006 You guys are Cool! Fixed it with the info. Twice I run into that white space problem now with PHP. Guess that might be a generic thing. Also, I had the same parse error and the missing quotes thing fixed it. Thanks Rich, Ronald and maxic0 Quote Link to comment https://forums.phpfreaks.com/topic/20322-php-white-space-only/#findComment-89566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.