nadz Posted April 15, 2007 Share Posted April 15, 2007 Hi, I've just recently bought hosting from dreamhost - I've finished setting up my flashchat based site and im just trying to integrate a contact importer script I bought from svetlozar. My problem is that dreamhost has a different way of using sendmail and i know only the extreme basic php (like embedding images). Now i need to edit the script to make it submit to dreamhosts formmail service instead of using the sendmail function directly. You can see info on dreamhost formmail service here: http://formmail.dreamhost.com and a txt version of the file that needs editing here: <?php include_once("settings.php"); if (!$_POST) { include("form.php"); } else if(!$_POST['formname'] || $_POST['formname'] != "invite") { include_once($scripts[$iscript]['filename']); $login = $_POST['username']; $password = $_POST['password']; $resultarray = get_contacts($login, $password); #if contacts were retreived successfully: if(is_array($resultarray)) { #the first array_shift of the result will give you the names in an array $names = array_shift($resultarray); #the second array_shift of the result will give you the emails $emails = array_shift($resultarray); if (!eregi("@", $login)) { $login = $login . "@" . strtolower($iscript) . ".com"; } echo '<div align="center" style="padding:5; background-color: #EEEEEE; width:350;">'; echo '<form method="POST" action="'.$formaction .'" name="inviteform" id="inviteform"><table style="background-color:white; border:black solid thin;">'; echo '<SCRIPT LANGUAGE="JavaScript">' ."\n" .' function togglechecked(){ ' . "\n" .' for (var i = 0; i < document.inviteform.elements.length; i++) {' . "\n" .' var e = document.inviteform.elements[i];' . "\n" ." if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {" ."\n" .' e.checked = document.inviteform.allbox.checked;' . "\n" .' }' . "\n" .' }' . "\n" .' }' . "\n" .' function toggleselect(){ ' . "\n" .' document.inviteform.allbox.checked = !document.inviteform.allbox.checked;' . "\n" .' togglechecked();}' . "\n" .' </SCRIPT>' . "\n"; echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"3\" align=\"center\"><h1 align=\"center\">Invite Contacts</h1>$logo</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>" . "<input type=\"checkbox\" name=\"allbox\" id=\"allbox\" value=\"nothing\" onClick=\"togglechecked()\" checked>" . '</td><td><b>Name</b></td><td><b>Email</b></td></tr>'; echo '<input type="hidden" name="formname" value="invite">'; echo "<input type=\"hidden\" name=\"sender\" value=\"$login\">"; $maxin = count($names); for ($i=0; $i<$maxin; ++$i) { $emails[$i] = trim($emails[$i]); if ($emails[$i]!="" && eregi("@", $emails[$i])) { $emails[$i] = strtolower($emails[$i]); echo "<tr><td>" . "<input type=\"checkbox\" name=\"addresses[]\" value=\"$emails[$i]\" checked>" . "</td><td>$names[$i]</td><td>$emails[$i]</td></tr>"; } } echo <<< _end_this <tr> <tr><td><input type="checkbox" name="allbox2" value="nothing" onClick="toggleselect()" checked></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td><td></td></tr> <td colspan="3" style="padding:4"><input name="submit" type="submit" value="Invite Selected" style="width:100%"></td> </tr> </table></form> <div align="center" style="color:#444444; font-size:11.5px; font-family:Arial, sans-serif; align:center; width:100%;">© 2006 Address Book Import Scripts Developed by <a href="http://svetlozar.net" target="_blank" style="color:#333333;">Svetlozar Petrov</a></div> </div> _end_this; } else #else print out the form with the error message { switch ($resultarray) { case 1: #invalid login $formdisclaimer = "<br><b style=\"color:red\">Invalid Login</b><br>"; break; case 2: #empty username or password $formdisclaimer = "<br><b style=\"color:red\">Enter Your Username and Password</b><br>"; break; } include("form.php"); } } else if ($_POST['formname'] == "invite") { $message = file_get_contents($basedir . $slash . "email.html"); $subject = file_get_contents($basedir . $slash . "emailsubject.txt"); $addressesStr = implode(",", $_POST['addresses']); $headers = ""; if ($fromfield && $fromfield!="") { $from = $fromfield; } else { $from = trim($_POST['sender']); $headers .= "From: $from\r\n"; } $headers .= "Bcc: $addressesStr" . "\r\n"; $message = str_replace("[[[sender]]]", $_POST['sender'], $message); $subject = str_replace("[[[sender]]]", $_POST['sender'], $subject); $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html;\r\n"; if(mail ($tofield, $subject, "\r\n". $message, $headers)) $msg = "Invites Sent"; else $msg = "Error occured"; echo <<< _end_sent <style type="text/css"> <!-- .formheading { color:black; font-size:24px; font-family:Arial, sans-serif; font-weight:bolder; } .scriptlinks a { color:blue; text-decoration:none; } --> </style> <div style="padding:5; background-color: #EEEEEE; width:350;"> <div style="width:340; border: black thin solid; background-color:white;" align="center"><h1>$msg</h1> <p class="scriptlinks">Invite more from $selects</p><br><br><br></div> <div align="center" style="color:#444444; font-size:11.5px; font-family:Arial, sans-serif; align:center;">© 2006 Address Book Import Scripts Developed by <a href="http://svetlozar.net" target="_blank" style="color:#333333;">Svetlozar Petrov</a></div> </div> _end_sent; } ?> any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/47093-help-with-sendmail/ Share on other sites More sharing options...
AV1611 Posted April 15, 2007 Share Posted April 15, 2007 do I understand that they already have a mail form they want you to use but you want to use your own? if so i suppose you could view source on that doc if possible then build your script to pass the same variables that they use... I think I did that once, but not on a mail script, but the theory is the same I suppose :/ Link to comment https://forums.phpfreaks.com/topic/47093-help-with-sendmail/#findComment-229706 Share on other sites More sharing options...
nadz Posted April 15, 2007 Author Share Posted April 15, 2007 thanks for your reply, its appreciated. Anyway, i dont want to use my own - im on shared hosting so i have no choice but to use the formmail service my host provides. I just need to know how to edit my script (which uses sendmail directly) to make it use the formmail service.This is what i got from my host: The action of your form needs to point towards this script, and the method must be POST or GET in capital letters. Therefore you must have this EXACT html in your form: <form action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="POST"> Link to comment https://forums.phpfreaks.com/topic/47093-help-with-sendmail/#findComment-229714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.