stever_stifler Posted August 31, 2016 Share Posted August 31, 2016 Hi! I'm looking for someone who can help me out with PHP script which meant to be launched on FTP server and ought to send some emails based on ready&made email templates written in HTML code. The basic script looks like this: <?php $receiver = "receiver@gmail.com"; $subject = "Subject example"; $message = "Message example"; $sender = "sender@gmail.com"; $header = "From: " . $from; mail($receiver, $subject, $message, $header); echo "ok!"; ?> What am I supposed to do to run this code with my HTML template and how should I organize files on my FTP server so that the script will be reading all content from HTML template including some graphic files which are used in this template ? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 31, 2016 Share Posted August 31, 2016 Does your ftp server ALSO run php? As for sending an html email, you need to include some additional headers to make that happen. As for the template, you will have to work that out as I'm sure you must have some bits of data that you want to insert into the rest of that html, no? You need to setup your template to incluee the dynamic parts as PHP vars and then just read that in and output into your $message var. Quote Link to comment Share on other sites More sharing options...
stever_stifler Posted August 31, 2016 Author Share Posted August 31, 2016 (edited) How do I do it exactly ? I did try to include entire HTML template sourcecode like that: $message = "<div>My entire sourcecode of HTML template </div>"; and unfortunately time and again when I launch the entire file on FTP server, by typing the address of ftp server with slash and the name of this file, I get the exactly same message -> (the sixth line starts with '<head> <xml>') 'Parse error: syntax error, unexpected '<' in /home/stevestifler/public_html/script.php on line 6' . Edited August 31, 2016 by stever_stifler Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 31, 2016 Share Posted August 31, 2016 (edited) Why do you keep mentioning FTP Server???? We don't care if it's an ftp server. We do care if it serves PHP otherwise your script won't run. How about showing us line 6 and the lines around it so we don't have to guess? Try and make it easier for use to help you! Also - do you have PHP error checking turned on??? Edited August 31, 2016 by ginerjm Quote Link to comment Share on other sites More sharing options...
stever_stifler Posted August 31, 2016 Author Share Posted August 31, 2016 (edited) I don't know why I keep mentioning it. It serves PHP for sure. The sixth line is the one that starts with <head> <?php $receiver = "receiver@gmail.com"; $subject = "Subject example"; $message = " <!DOCTYPE html "-//w3c//dtd xhtml 1.0 transitional //en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <xml> <o:OfficeDocumentSettings> [...] Also - do you have PHP error checking turned on??? Yes, I do. The message I get is: Parse error: syntax error, unexpected '<' in /home/steve_stifler/public_html/test.php on line 6 Edited August 31, 2016 by stever_stifler Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 31, 2016 Share Posted August 31, 2016 Do you not know anything about strings and quotes and single quotes? Your html is wrongly quoted. Look at it. Quote Link to comment Share on other sites More sharing options...
stever_stifler Posted August 31, 2016 Author Share Posted August 31, 2016 Should I use single apostropthe than or what ? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 31, 2016 Share Posted August 31, 2016 It doesn't matter. You just have to ensure that anything that is meant to be part of $message is included in the string you assign to it. If you can't handle a simple string assignment at this point you probably shouldn't be tackling this project. I'm not going to show you cause that's the kind of guy I am. Figure it out yourself and you will have learned; have me do it and you don't learn a thing. Quote Link to comment Share on other sites More sharing options...
stever_stifler Posted August 31, 2016 Author Share Posted August 31, 2016 Sure, but I'm not asking for the entire code, and giving me the solutions take about... 1 line of code. It's just pity that I came across this forum and I'm wasting my time, listening to people who think they are smart just because there's a newbie member of this community. Not to mention, that it took you more time to write your silly and how 'enlightening' comment than it would've take to modify a single line of code. This forum is complete waste of time. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 31, 2016 Share Posted August 31, 2016 It's a complete waste of time in your entire learning experience no matter where you go if YOU don't take the time to do some reading and research to advance your OWN knowledge. Have a good life. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 31, 2016 Share Posted August 31, 2016 This forum is complete waste of time. GFY. He walked you through the entire process and explained exactly what you need to do, and now you complain that he doesn't fix the code for you? Do you need help finding the quotes on your keyboard, or what? Quote Link to comment Share on other sites More sharing options...
benanamen Posted August 31, 2016 Share Posted August 31, 2016 OP, you need to Romeo Tango Foxtrot Mike. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted September 1, 2016 Share Posted September 1, 2016 (edited) Should I use single apostropthe than or what ? For what it's worth, you are assigning a string to $message on the following line: $message = " Since your string starts with a double quote ("), PHP will look for the next double quote to determine where the end of the string is. So basically, PHP thinks this is the string to assign to $message: " <!DOCTYPE html " ...and it's not going to know what to do with the rest, hence the error. To prevent PHP from cutting the string off early, you need to use care with double quotes that appear within the [double-quoted] string. You could replace them with single quotes ('), where possible. Or you can escape the double quotes (\"). Or you could even consider using the heredoc or nowdoc syntax. More information about all of these tactics can be found here: http://php.net/manual/en/language.types.string.php Edited September 1, 2016 by cyberRobot Quote Link to comment 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.