FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Email Using PHP





guissmo
How do I email using PHP? I've never had any formal PHP lessons though I've researched some to get my codes working, so please be easy on the technical terms. Very Happy

I've tried using some snippet I found online, but using the localhost, it seems impossible. Any tips on this?
rickylau
guissmo wrote:
How do I email using PHP? I've never had any formal PHP lessons though I've researched some to get my codes working, so please be easy on the technical terms. Very Happy

I've tried using some snippet I found online, but using the localhost, it seems impossible. Any tips on this?
Why don't you simply use mail function? It just fit if nothing special is needed:
Code:
mail (receiver, subject, message);
guissmo
I'm encountering some errors when I use localhost (no "from" email address).
Will I not encounter them when I upload?
Or how do I fix this in localhost so that I could also learn the problem behind it.
rickylau
Maybe you have to configure [mail function] section to get it work? (Windows server?)

Or if it doesn't work, phpmailer class would be easy too (a bit more difficult comparing to php's native mail function in my opinion).

I'm using 2.0.0 version of it (not sure if newer version changed a lot), and code like this works for me:
Code:

include("class.phpmailer.php");
include("class.smtp.php");

$mailer=new PHPMailer ();
$mailer->IsSMTP ();
$mailer->SMTPAuth = true;
$mailer->Host = 'localhost'; // I have SMTP server on the same host, with SSL authenication
$mailer->Port = 587;
$mailer->Username = $smtp_username;
$mailer->Password = $smtp_password;
$mailer->From = $email_from_address;
$mailer->FromName = $email_from_name;
$mailer->Subject = $email_subject;
$mailer->Body = $email_message;
$mailer->AddAddress ($email_to_address, $email_to_name);
$mailer->IsHTML (true); // mail message in HTML
if ($mailer->Send ()) {
  // What to do if mail sent
} else {
  // Otherwise
}
mathiaus
PHP doesn't actually send email, that is why you have to specify an email server. If you use localhost, on the same machine you should be running an smtp server which will send the mail.
Try using postcast server free edition -> http://www.postcastserver.com/download/
Or specify an other mail server, if you use hotmail/gmail etc, try those.
tukun2009manit
guissmo wrote:
How do I email using PHP? I've never had any formal PHP lessons though I've researched some to get my codes working, so please be easy on the technical terms. Very Happy

I've tried using some snippet I found online, but using the localhost, it seems impossible. Any tips on this?


go to w3schools search on google then find php tutorial its one of best tutorial he will explain u the rest
blueray
Before you can send mail using php's mail function.
You have to configure a smtp server and its port.
Also, that smtp server must allow anonymous to send or relay mail.
Otherwise, it will not allow you to send any mail.
Because of this. You should install a smtp server on the localhost.

In addition, you will need to specific the from header on the fourth parameter of the mail function.

mail ('admin@frihost.com', 'subject', 'message', 'from: mod@frihost.com');

or

setting up the from header as a fixed address from the php.ini's sendmail_from directive.
aningbo
localhost would be difficult. you will have to setup SMTP and all that.

its not worth it if u r gonna use it as a full email system since u can't switch it on all the time.
Diablosblizz
Keep in mind that if you use localhost for a SMTP server you MUST (!!) have permission from your ISP. I've had a few emails come to my account stating that I've been sending out emails. Of course, I was just testing and fooling around.

Another way is setting the SMTP server and login information in the PHP.ini file, and it will use that SMTP server to send out mail from localhost. Don't remember how to do this, but it is possible.
figola
pls i need free e-mail box that can carry at least 500 mails,pls help me.
sonam
figola wrote:
pls i need free e-mail box that can carry at least 500 mails,pls help me.


It is better to open new topic and explain us what do you mean with "carry at least 500 mails" then post in old one. If you want mailing list then you can create one in your control panel.

Sonam
Related topics
Using PHP's built in mail() to modify the from attribute.
[tutor] How to protect images without htaccess using PHP
Using PHP
Includ Images using PHP.
How to start using PHP? Help!
Website Designing using PHP
how can i setup a page break for printer on html using php ?
Reading word documents using PHP?
I am trying to build a contact form using php and flash
Communicating between web pages
how to compress a file using php ?
Checking if ports are up using PHP
Hot to change "Reset Ownership" using php?
Using php to change content of a .txt
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.