Jump to content

Setting up email


squigs

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.