didster Posted November 14, 2008 Share Posted November 14, 2008 Hi, can anybody please help me. I am looking to change my code to accommodate this email reply. Is it reletively straight forward to do this? Thank you The email that I recieved from the hosts was... The smtp server to use is smtp.danahermail.com. We are not allowed to send out email on our own. It must go to smtp.danahermail.com then it will go out from there 1. 2. <?php 3. 4. error_reporting(E_ALL); 5. ini_set("display_errors", 1); 6. 7. // ------------- CONFIGURABLE SECTION ------------------------ 8. 9. $to = '[email protected]' ;// $subject - set to the Subject line of the email, eg 10. //$subject = "Feedback Form" ; 11. 12. $subject = "Plug Gauge Quote Request Form" ; 13. 14. $formurl = "/pluggauge.htm"; 15. $errorurl = "/enquiryform/error.htm" ; 16. $thankyouurl = "/enquiryform/thankyou.htm" ; 17. 18. 19. // -------------------- END OF CONFIGURABLE SECTION --------------- 20. 21. 22. $contactname = $_POST['contactname'] ; 23. $companyname = $_POST['companyname'] ; 24. $currentaddress = $_POST['currentaddress'] ; 25. $contactnumber = $_POST['contactnumber'] ; 26. $rfqreference = $_POST['rfqreference'] ; 27. $teeth = $_POST['teeth'] ; 28. $dpmoduletext = $_POST['dpmoduletext'] ; 29. $dpmoduledrop = $_POST['dpmoduledrop'] ; 30. $pressureangle = $_POST['pressureangle'] ; 31. $helixangle = $_POST['helixangle'] ; 32. $helixhand = $_POST['helixhand'] ; 33. $pitchtext = $_POST['pitchtext'] ; 34. $pitchdrop = $_POST['pitchdrop'] ; 35. $gauge = $_POST['gauge'] ; 36. $typefit = $_POST['typefit'] ; 37. $facetext = $_POST['facetext'] ; 38. $facedrop = $_POST['facedrop'] ; 39. $quantity = $_POST['quantity'] ; 40. $materials = $_POST['materials'] ; 41. $notes = $_POST['notes'] ; 42. 43. 44. $chknotest = $_POST['chkno'] ; 45. 46. 47. // Read POST request params into global vars 48. 49. $from = $_POST['from']; 50. 51. // Obtain file upload vars 52. $fileatt = $_FILES['fileatt']['tmp_name']; 53. $fileatt_type = $_FILES['fileatt']['type']; 54. $fileatt_name = $_FILES['fileatt']['name']; 55. 56. $headers = "From: $from"; 57. 58. $file = fopen($filesize, 'rb'); 59. if (filesize($fileatt)==0){} 60. else{$page_content = fread($file, filesize($fileatt));} 61. 62. // Generate a boundary string 63. $semi_rand = md5(time()); 64. $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 65. 66. $message .= 67. 68. "\n\n-- Chk --\n\n" . 69. 70. $_POST['chkno'][0] . 71. $_POST['chkno'][1] . 72. $_POST['chkno'][2] ; 73. 74. if (!empty($contactname)) { 75. $message .= "\n\n-- Contact Name --\n\n" . $contactname; 76. } 77. 78. if (!empty($companyname)) { 79. $message .= "\n\n-- Company Name --\n\n" . $companyname; 80. } 81. 82. if (!empty($currentaddress)) { 83. $message .= "\n\n-- Current Address --\n\n" . $currentaddress; 84. } 85. 86. if (!empty($contactnumber)) { 87. $message .= "\n\n-- Contact Number --\n\n" . $contactnumber; 88. } 89. 90. if (!empty($rfqreference)) { 91. $message .= "\n\n-- RFQ Reference Number --\n\n" . $rfqreference; 92. } 93. 94. if (!empty($teeth)) { 95. $message .= "\n\n-- Teeth --\n\n" . $teeth; 96. } 97. 98. if (!empty($dpmoduletext)) { 99. $message .= "\n\n-- DP Module Text --\n\n" . $dpmoduletext; 100. } 101. 102. if (!empty($dpmoduledrop)) { 103. $message .= "\n\n-- DP Module Drop --\n\n" . $dpmoduledrop; 104. } 105. 106. if (!empty($pressureangle)) { 107. $message .= "\n\n-- Pressure Angle --\n\n" . $pressureangle; 108. } 109. 110. if (!empty($helixangle)) { 111. $message .= "\n\n-- Helix Angle --\n\n" . $helixangle; 112. } 113. 114. if (!empty($helixhand)) { 115. $message .= "\n\n-- Helix Hand --\n\n" . $helixhand; 116. } 117. 118. if (!empty($pitchtext)) { 119. $message .= "\n\n-- Pitch Text (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchtext; 120. } 121. 122. if (!empty($pitchdrop)) { 123. $message .= "\n\n-- Pitch Drop (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchdrop; 124. } 125. 126. if (!empty($gauge)) { 127. $message .= "\n\n-- Gauge Ref/Tool No. --\n\n" . $gauge; 128. } 129. 130. if (!empty($typefit)) { 131. $message .= "\n\n-- Type Fit --\n\n" . $typefit; 132. } 133. 134. if (!empty($facetext)) { 135. $message .= "\n\n-- Face Width Text --\n\n" . $facetext; 136. } 137. 138. if (!empty($facedrop)) { 139. $message .= "\n\n-- Face Width Drop --\n\n" . $facedrop; 140. } 141. 142. if (!empty($quantity)) { 143. $message .= "\n\n-- Quantity --\n\n" . $quantity; 144. } 145. 146. if (!empty($materials)) { 147. $message .= "\n\n-- Materials --\n\n" . $materials; 148. } 149. 150. if (!empty($notes)) { 151. $message .= "\n\n-- Notes --\n\n" . $notes; 152. } 153. 154. 155. // Add the headers for a file attachment 156. $headers .= "\nMIME-Version: 1.0\n" . 157. "Content-Type: multipart/mixed;\n" . 158. " boundary=\"{$mime_boundary}\""; 159. 160. // Add a multipart boundary above the plain message 161. $message = "This is a multi-part message in MIME format.\n\n" . 162. "--{$mime_boundary}\n" . 163. "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 164. "Content-Transfer-Encoding: 7bit\n\n" . 165. $message . "\n\n"; 166. 167. // Base64 encode the file data 168. $data = chunk_split(base64_encode($data)); 169. 170. // Add file attachment to the message 171. $message .= "--{$mime_boundary}\n" . 172. "Content-Type: {$fileatt_type};\n" . 173. " name=\"{$fileatt_name}\"\n" . 174. //"Content-Disposition: attachment;\n" . 175. //" filename=\"{$fileatt_name}\"\n" . 176. "Content-Transfer-Encoding: base64\n\n" . 177. $data . "\n\n" . 178. "--{$mime_boundary}--\n"; 179. 180. 181. $http_referrer = getenv( "HTTP_REFERER" ); 182. 183. if (!isset($_POST['from'])) { 184. header( "Location: $formurl" ); 185. exit ; 186. } 187. 188. if (empty($contactname) || empty($from) || empty($companyname) || empty($contactnumber) || empty($teeth) || empty($quantity) || empty($chknotest)/* || empty($dpmoduletext) || empty($dpmoduledrop) || empty($currentaddress) || empty($rfqreference) || empty($pressureangle) || empty($helixangle) || empty($helixhand) || empty($pitchtext) || empty($pitchdrop) || empty($gauge) || empty($typefit) || empty($facetext) || empty($facedrop) || empty($quantity) || empty($materials) ||empty($notes) */) { 189. header( "Location: $errorurl" ); 190. exit ; 191. } 192. 193. 194. $contactname = strtok( $contactname, "\r\n" ); 195. $email = strtok( $email, "\r\n" ); 196. if (get_magic_quotes_gpc()) { 197. 198. $chkno = stripslashes( $chkno ); 199. 200. $companyname = stripslashes( $companyname ); 201. $currentaddress = stripslashes( $currentaddress ); 202. $contactnumber = stripslashes( $contactnumber ); 203. $rfqreference = stripslashes( $rfqreference ); 204. $teeth = stripslashes( $teeth ); 205. $dpmoduletext = stripslashes( $dpmoduletext ); 206. $dpmoduledrop = stripslashes( $dpmoduledrop ); 207. $pressureangle = stripslashes( $pressureangle ); 208. $helixangle = stripslashes( $helixangle ); 209. $helixhand = stripslashes( $helixhand ); 210. $pitchtext = stripslashes( $pitchtext ); 211. $pitchdrop = stripslashes( $pitchdrop ); 212. $gauge = stripslashes( $gauge ); 213. $typefit = stripslashes( $typefit ); 214. $facetext = stripslashes( $facetext ); 215. $facedrop = stripslashes( $facedrop ); 216. $quantity = stripslashes( $quantity ); 217. $materials = stripslashes( $materials ); 218. $notes = stripslashes( $notes ); 219. } 220. 221. 222. ini_set("sendmail_from", $email); 223. 224. mail($to, $subject, $message, $headers); 225. header( "Location: $thankyouurl" ); 226. exit ; 227. 228. ?> Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/ Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 is this a windows based server? either way, you host should have PHP configured to properly send mail...it's not something you should have to do. if it's a windows system, after this line: ini_set("sendmail_from", $email); try adding this line: ini_set("smtp", 'smtp.danahermail.com'); Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690130 Share on other sites More sharing options...
didster Posted November 14, 2008 Author Share Posted November 14, 2008 Thank you for that although it still doesnt seem to be working. It is a windows server, I have added an infofile for you to have a look at, to see if there is anything on there. Thank you for helping http://www.splinegauges.co.uk/phpinfo.php Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690141 Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 so...just noticed something...where is $email getting set? if you echo it, does it have a value? before the ini_set function, do: echo $email; also, for testing purposes, try setting that to something static to see if it works: ini_set("sendmail_from", '[email protected]'); Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690144 Share on other sites More sharing options...
didster Posted November 14, 2008 Author Share Posted November 14, 2008 I put the echo where you said but it didnt show up on screen, I put a print there as well and that didnt. Is it because it goes to the 'thankyou' or 'error' pages before it has chance to show? print ("Hello World! <br />"); echo ("Hello World! <br />"); Just for testing purposes, I just used the exact same script on my own server and it was fine! And the two hello worlds showed up! Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690167 Share on other sites More sharing options...
didster Posted November 14, 2008 Author Share Posted November 14, 2008 I just tried it on my server with the echo $email; command and it didnt come up with anything. As you can see I am a beginner. I would love to get into PHP more though Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690169 Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 did you try setting the sendmail_from a static email address instead of $email (look a couple posts back) Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690172 Share on other sites More sharing options...
didster Posted November 14, 2008 Author Share Posted November 14, 2008 Yeah I tried it, again, it works fine on my server, not on the clients. I get the thankyou message up but I never recieve the email. Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690178 Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 what if you just run a simpler version...if you put this in another script, does it work? <?php mail('[email protected]','Test Message','This is the contents of the test message'); print 'Done'; ?> obviously replace [email protected] with your email address ...if the above doesn't work, then you need to tell the hosting company to fix their server. Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-690233 Share on other sites More sharing options...
didster Posted November 20, 2008 Author Share Posted November 20, 2008 Hi Rhodesa, You were right, it was my web hosts, thankyou for helping me with this. Link to comment https://forums.phpfreaks.com/topic/132697-solved-smtp-email/#findComment-694464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.