squigs Posted November 25, 2010 Share Posted November 25, 2010 Hi there, I'm browsing the web for any articles or tutorials on how I could design a webpage that would allow me to send/receive emails from my webpage. I currently have email addresses set up in cpanel but I'm lacking the knowledge of how I could set that up on my site. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/ Share on other sites More sharing options...
aabid Posted November 25, 2010 Share Posted November 25, 2010 You can easily search them on Google, there are thousands of ready made scripts available and you can pick any of them. Here is the one for you, Mail.html <html> <head><title>Mail sender</title></head> <body> <form action="mail.php" method="POST"> <b>Email</b><br> <input type="text" name="email" size=40> <p><b>Subject</b><br> <input type="text" name="subject" size=40> <p><b>Message</b><br> <textarea cols=40 rows=10 name="message"></textarea> <p><input type="submit" value=" Send "> </form> </body> </html> Mail.php <html> <head><title>PHP Mail Sender</title></head> <body> <?php /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */ $email = $HTTP_POST_VARS['email']; $subject = $HTTP_POST_VARS['subject']; $message = $HTTP_POST_VARS['message']; /* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */ if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif ($subject == "") { echo "<h4>No subject</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */ elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139357 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2010 Share Posted November 25, 2010 I know the point was that there are lot of email scripts that can be found online, but they aren't all good. From the looks of that one, it's outdated; it uses $HTTP_POST_VARS, which has been deprecated since PHP 4.1. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139377 Share on other sites More sharing options...
aabid Posted November 25, 2010 Share Posted November 25, 2010 I know the point was that there are lot of email scripts that can be found online, but they aren't all good. From the looks of that one, it's outdated; it uses $HTTP_POST_VARS, which has been deprecated since PHP 4.1. well you can modify it a bit to make it more aligned but the concept is same for all. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139384 Share on other sites More sharing options...
squigs Posted November 25, 2010 Author Share Posted November 25, 2010 I'm sorry if my post was misunderstood. I have a mail delivery set up for form mail already. I am wondering if I can set up a page where administrators can login and actually view received emails without visiting cpanel and logging in. Basically I would like to style the page to look like the rest of my site and be able to retrieve my emails which I can already do through cpanel but I would rather do it without logging into to cpanel instead just logging into a page on my site. I'm not sure if this sort of thing is even possible but any input would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139571 Share on other sites More sharing options...
Adam Posted November 25, 2010 Share Posted November 25, 2010 I know the point was that there are lot of email scripts that can be found online, but they aren't all good. From the looks of that one, it's outdated; it uses $HTTP_POST_VARS, which has been deprecated since PHP 4.1. well you can modify it a bit to make it more aligned but the concept is same for all. The "concept" being they all use mail? Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139649 Share on other sites More sharing options...
squigs Posted November 25, 2010 Author Share Posted November 25, 2010 I've continued to look into this and what I have come up with is some resources outlining creating a login script for some of the mail services that are pre-installed with my web host through cpanel. I am having difficulty implementing these scripts as my webhost maintains the main installation files of these mail programs. Currently there is the selection of three programs to choose from, Hoarde mail, Squirrel mail, and roundcube. Does anyone have any experience setting up login scripts to really try to tie the website together with the mail program (especially with it being maintained on a server by a webhost). Or alternatively can anyone help point me in the direction of something that would fit my needs better than a login script that bypasses a cpanel login? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139682 Share on other sites More sharing options...
JonnoTheDev Posted November 26, 2010 Share Posted November 26, 2010 You can connect to any pop3 mailbox and issue commands using PHP with the following functions: fsockopen fgets fputs Using fputs() you can issue the following commands: LIST - list all messages RETR x - get message number x DELE x - delete message number x QUIT - close mailbox Try the following: http://www.phpclasses.org/package/2-PHP-Access-to-e-mail-mailboxes-using-the-POP3-protocol.html Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139867 Share on other sites More sharing options...
tomfmason Posted November 26, 2010 Share Posted November 26, 2010 To make my life easier I generally use phpmailer. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1139996 Share on other sites More sharing options...
JonnoTheDev Posted November 26, 2010 Share Posted November 26, 2010 To make my life easier I generally use phpmailer. Isn't that just for sending mail, like swiftmailer? The user wants the ability to open pop3 mailboxes and display the messages on his website for the user that is logged in sort of like a webmail client. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140002 Share on other sites More sharing options...
squigs Posted November 26, 2010 Author Share Posted November 26, 2010 The user wants the ability to open pop3 mailboxes and display the messages on his website for the user that is logged in sort of like a webmail client. Exactly, I take it I need to register to your suggested link in order to get the full benefits of what I am seeking so I will do so. It will probably take a bit of research and trial and error before I am able to implement this sort of system. Thanks for your replies and I will post back with progress or lack there of reports. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140020 Share on other sites More sharing options...
squigs Posted November 26, 2010 Author Share Posted November 26, 2010 I thought that this sort of thing would be far more popular than it is turning out to be. It is going to be a long, tough go pulling enough resources together to create the sort of thing I have in mind. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140039 Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 Why not take an existing open source script and integrate it? A quick google search for "php pop3 webmail script" turned up this http://www.hotscripts.com/listing/nocc/, along with about 209,999 others. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140095 Share on other sites More sharing options...
squigs Posted November 26, 2010 Author Share Posted November 26, 2010 Its funny you posted that! I was just checking it out myself. I am having difficulty implementing it correctly. Despite it being fairly well documented it is still a little over my head. I seem to be running into troubles due to the fact that I am not sure exactly what domain name and ports to use. This is one of the examples that the script provides and I'm not sure if it is the example I should follow. // ex for a pop3 server: // mail.sourceforge.net:110/pop3 However I have saved a registry script from my webmail that is intended to setup my microsoft outlook (which i do not wish to do) and it shows me something that looks like this. "POP3 Server"="cwh2.canadianwebhosting.com" "POP3 Port"=dword:000003e3 I have seen in a couple scripts that the standard port seems to be 110 and the confusion is setting in due to the fact that my webmail is delivered through my webhost (canadian web hosting) Anyways if you know how to configure this properly it would be a great deal of help. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140112 Share on other sites More sharing options...
squigs Posted November 27, 2010 Author Share Posted November 27, 2010 I've got nooc now working partially, that is to say I can receive mails on it however when I try to send emails out I get the following An error occurred : : 250-AUTH PLAIN LOGIN The only thing I can think of is this <?php // $conf->domains[$i]->smtp_auth_method = ''; // Select SMTP AUTH method. // Supported AUTH methods are : // '' : no authentification method // 'PLAIN' : AUTH PLAIN method // 'LOGIN' : AUTH LOGIN method ?> and the following code i leave as such <?php $conf->domains[$i]->smtp_auth_method = ''; ?> If anyone has any experience with tht=is error or this particular code your help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140154 Share on other sites More sharing options...
Pikachu2000 Posted November 27, 2010 Share Posted November 27, 2010 That's strange. A 250 response doesn't indicate an error, it means the requested action completed. Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140157 Share on other sites More sharing options...
squigs Posted November 27, 2010 Author Share Posted November 27, 2010 Well I got it working, turns out less information is better. What I did in the end was just not enter any info regarding my smtp and voila. Now its just a matter of cleaning out a lot of code out of this script and styling it to my website. Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/219760-setting-up-email/#findComment-1140391 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.