MKMD555 Posted January 26, 2009 Share Posted January 26, 2009 Sorry to ask such a simple question, but it has baffled me. I use Win Vista and Wamp I can't configure mail. I use Yahoo or gmail they both need authentification. Where and how should I edit the php ini? Best regards M Khan Link to comment https://forums.phpfreaks.com/topic/142553-newbie-needs-help-for-mail/ Share on other sites More sharing options...
uniflare Posted January 27, 2009 Share Posted January 27, 2009 For Development Purposes: There are free SMTP servers that run just like wamp does on your system, this will enable you to send the sendmail/mail path to "localhost", some of these free smtp server programs are very unstable and only work half the time. SMTP Authentication Options I would however reccommend using a Mailer Class, either the PEAR::Mail Constructs or the PHPMailer class (or similar). There are lots of Mailer classes(free) out there with support for authentication. Link to comment https://forums.phpfreaks.com/topic/142553-newbie-needs-help-for-mail/#findComment-747094 Share on other sites More sharing options...
redarrow Posted January 27, 2009 Share Posted January 27, 2009 You can also add your smtp of your current isp to the php.ini , that will only help if your isp allows you to send emails. usually isp block port 25, unless your using a authentication mailing code as below advised. if you do, go down the road off setting up a mail server, on a computer then your need to have a mail server program that supports http/smtp and lets you use a relay within it. the relay config of the new installed email server program, lets you use a username and password to bypass your current isp config. this then will let you send emails and receive emails as a proper email server. Link to comment https://forums.phpfreaks.com/topic/142553-newbie-needs-help-for-mail/#findComment-747097 Share on other sites More sharing options...
haku Posted January 27, 2009 Share Posted January 27, 2009 I've used this method in the past: http://www.joshstauffer.com/2008/01/send-test-emails-with-wampserver/ Link to comment https://forums.phpfreaks.com/topic/142553-newbie-needs-help-for-mail/#findComment-747154 Share on other sites More sharing options...
redarrow Posted January 27, 2009 Share Posted January 27, 2009 there you go. works perfect. <?php //new function $to = "what [email protected]"; $nameto = "redarrow"; $from = $to; $namefrom = "redarrow"; $subject = "Hello World Again!"; $message = "World, Hello!"; authSendEmail($from, $namefrom, $to, $nameto, $subject, $message); ?> <?php /* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */ //Authenticate Send - 21st March 2005 //This will send an email using auth smtp and output a log array //logArray - connection, function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) { //SMTP + SERVER DETAILS /* * * * CONFIGURATION START * * * */ $smtpServer = "smtp.what_ever.co.uk"; $port = "25"; $timeout = "30"; $username = "what ever"; $password = "what ever"; $localhost = "localhost"; $newLine = "\r\n"; /* * * * CONFIGURATION END * * * * */ //Connect to the host on the specified port $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); $smtpResponse = fgets($smtpConnect, 515); if(empty($smtpConnect)) { $output = "Failed to connect: $smtpResponse"; return $output; } else { $logArray['connection'] = "Connected: $smtpResponse"; } //Request Auth Login fputs($smtpConnect,"AUTH LOGIN" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authrequest'] = "$smtpResponse"; //Send username fputs($smtpConnect, base64_encode($username) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authusername'] = "$smtpResponse"; //Send password fputs($smtpConnect, base64_encode($password) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authpassword'] = "$smtpResponse"; //Say Hello to SMTP fputs($smtpConnect, "HELO $localhost" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['heloresponse'] = "$smtpResponse"; //Email From fputs($smtpConnect, "MAIL FROM: $from" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailfromresponse'] = "$smtpResponse"; //Email To fputs($smtpConnect, "RCPT TO: $to" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailtoresponse'] = "$smtpResponse"; //The Email fputs($smtpConnect, "DATA" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['data1response'] = "$smtpResponse"; //Construct Headers $headers = "MIME-Version: 1.0" . $newLine; $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine; $headers .= "To: $nameto <$to>" . $newLine; $headers .= "From: $namefrom <$from>" . $newLine; fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Say Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } ?> Link to comment https://forums.phpfreaks.com/topic/142553-newbie-needs-help-for-mail/#findComment-747161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.