aliciamee Posted March 4, 2009 Share Posted March 4, 2009 I eagerly need to write a code that will send out email after the matching of the email address key in by the user in webpage with the address in database. But i am new in php so i try out some simple code as below: <?php // The message $message = "Line 1\nLine 2\nLine 3"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('mysite@yahoo.com', 'My Subject', $message); echo" mail sends"; ?> I try to send to yahoo and hotmail but both in vain. i wonder why it didn't work or there are some settings that need to be done? I using apache2triad and i didn't go and change the settings inside. I save the above code as test.php in C:\apache2triad\htdocs and run in browser by typing http://localhost/test.php. Am my steps correct? Hope to hear replies soon... ??? Quote Link to comment Share on other sites More sharing options...
elflacodepr Posted March 4, 2009 Share Posted March 4, 2009 You need a working email system which will receive the info from PHP and send it to your 'Yahoo' email, because as plain as you are doing it will not work Quote Link to comment Share on other sites More sharing options...
aliciamee Posted March 4, 2009 Author Share Posted March 4, 2009 What do u mean by a working email system, can u be more specific? Sorry because i have very less knowledge in these things... Quote Link to comment Share on other sites More sharing options...
aliciamee Posted March 5, 2009 Author Share Posted March 5, 2009 Can anyone explain to me in more details coz i'm really need to solve the problem in a short time? Does apache2triad provide the working email system? Quote Link to comment Share on other sites More sharing options...
aliciamee Posted March 6, 2009 Author Share Posted March 6, 2009 Do u mean in nid to setup smtp server? I nid a easiest way for the setup so will it be fine if i juz installed program like freesmtp? It is a free SMTP server program to send emails directly from PC. Quote Link to comment Share on other sites More sharing options...
aliciamee Posted March 23, 2009 Author Share Posted March 23, 2009 I still facing the same problem. Can anyone tell how to setup for proper working email system as told by elflacodepr? Plz help me.............. :'( Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 23, 2009 Share Posted March 23, 2009 to have a proper email system you need to have a email server installed.. read this please. http://www.sitepoint.com/article/advanced-email-php/ there other ways aswell. Quote Link to comment Share on other sites More sharing options...
aliciamee Posted April 5, 2009 Author Share Posted April 5, 2009 Can u answer me a few questions? i have look through a lot of link and forum regarding this issue but i still very very blur. Below is part of things i found: [mail function] ; For Win32 only. SMTP = smtp.sbcglobal.yahoo.com ;(note: you need to find your own smtp the company that u pay to give you internet has one of these just google it what my smtp?) ; for Win32 only smtp_port = 25 sendmail_from= johny33@sbcglobal.net ; (place here the email that the company that you pay to give u internet gives u if u dont know it call them and ask them "whats my username?" and that is usually it) for Win32 only ; For Win32 only. ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = As stated above i need to contact company to get the info, if i don't know who to call, can i get the info elsewhere? Can i use gmail as a mail server? What i need to do is sending email from localhost to either gmail, yahoo or hotmail. I using the package of apache2triad. Please reply me as soon as possible. I already very very confuse... I will go through the link u post, hope will make me clearer. Thanks!!! :-\ Quote Link to comment Share on other sites More sharing options...
aliciamee Posted April 6, 2009 Author Share Posted April 6, 2009 Redarrow, i have look through the link but i still have the same doubt at this part: SMTP = smtp.my.isp.net sendmail_from = me@myserver.com i have try to get a trial domain from tzo, so that i can get it works with the argosoft. The trial domain: user.tzo.net (user mention here is the name i choose). i even try to get a dns server: user.homedns.org if so how i need to set my SMTP and sendmail_from above? the above domain n dns can be used? i keep on getting this error: [Tue Apr 07 00:24:09 2009] [error] [client 127.0.0.1] File does not exist: C:/apache2triad/htdocs/000041237889296680.wmv, referer: http://xlissue110.sandai.net Please clear my doubt... Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 7, 2009 Share Posted April 7, 2009 This code will get your mail working. 1. you must ring your broadband provider and get the smtp. 2. you must ask for a password for mail service. 3. you must also ask for a user name for the mail service. once you got all that info, you just fill it in on this script and mail will work. it the easy way then installing a mail server, how it work. once all the information is provided, this script will first cheek your, smpt then your user name, then your password, if it all correct, then it sends the mail re bounding off, of your isp email server account. i personally used the code when, i couldn't understand, mail server's. you could in thory use the code to setup a service like hotmail.com if you wanted. <?php //new function $to = "contact_someone@what_ever.com"; $nameto = "person's name"; $from = "you_at@what_ever.com";// this must be filled in or your get //messages landing as spam. $namefrom = "the person it from"; $subject = "Hello World Again!"; $message = "World, Hello!"; authSendEmail($from, $namefrom, $to, $nameto, $subject, $message); ?> <?php /* * * * * * * * * * * * * * SEND EMAIL FUNCTIONS * * * * * * * * * * * * * */ //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.my_isp_name.co.uk"; $port = "25"; // my port. $timeout = "30";// my time out. $username = "username for your isp email provider, this comes from your isp broadband line //people"; $password = "the password the isp, just gave you to access you email account, from your //broadband provider"; $localhost = "localhost";//default. $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"; } ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 7, 2009 Share Posted April 7, 2009 The only other advice i can give, if you got a router inline off your isp broad band box. You will have to froward the current ip, that the computer got apache/php running to port 25 and then create another entry and foward the same ip with port 110. this enables the router to open port 25 for mail and port 110 also for mail. WARNING. it very important you ask your isp, while on the phone what port there sending mail from. because you re bouncing the email off of there email server, even if there blocking that port directly, it wont matter for you, because your using there isp email server account with authentication it will work, but not directly from php.ini as the php.ini has not got the ability to use authentication to send email's yet!. most isp are blocking port 25, and asking user's to log into there web account online, to send and receve email's, but with that same information with the code below will send emails directly in a php project. there you go a book in 2 posts lol. Quote Link to comment Share on other sites More sharing options...
aliciamee Posted April 12, 2009 Author Share Posted April 12, 2009 I keep on getting this error:[error] [client 127.0.0.1] File does not exist: C:/apache2triad/htdocs/000041237889296680.wmv, referer: http://xlissue110.sandai.net If i send through the mail server of my school, do i still need to setup my own mail server? I using the wireless connection of my school, so my ISP is refer to my school or to the people help to provide the service to my school? Thanks!!! 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.