|
-
Nov 18th, 2008, 04:35 PM
#1
Thread Starter
Hyperactive Member
Silly email question
I am using WAMP, how can I test sending emails with PHP? Is it possible or do I need to be on a legit webhost like godaddy?
-
Nov 18th, 2008, 06:28 PM
#2
Re: Silly email question
No you don't need to be on a webhost.
In your php.ini configuration file, there are settings for the outgoing mail server (SMTP). Open up your php.ini and look for these settings:
You should be able to test mail in PHP using your Internet Service Providers SMTP server, and your email account with them.
I don't know if you know how to actually send the mail in a script but the easiest way is the mail() function.
-
Nov 19th, 2008, 12:15 PM
#3
Frenzied Member
Re: Silly email question
Guess fixed, but when I started with php (using wamp also) there was a bug (or I was mistaken) with mail() on a windows server.
So I got used to using phpmailer, and still use it. Very usefull and easy to use.
Off course you first have to do what theguy said. Unless you allready set that up right when installing wamp server (guess u do use it)
-
Nov 24th, 2008, 08:28 PM
#4
Thread Starter
Hyperactive Member
Re: Silly email question
Can I use my gmail account?
-
Nov 24th, 2008, 08:36 PM
#5
Frenzied Member
Re: Silly email question
1 Download PHPMailer from http://phpmailer.sourceforge.net
2 Extract to folder phpmailer
3 Create a file email.php
4 Paste this code and change the values as you need
Code:
IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "[email protected]"; //Reply to this email ID
$email="[email protected]"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
5 Open the file class.smtp.php in phpmailer directory
6 Paste this code
Code:
$host = "ssl://smtp.gmail.com";
$port = 465;
before the line 104 #connect to the smtp server
Hint: Search for #connect
7 Open this page in browser and it will send the email using GMail.
Hint: When you want to email the details from a form, set the variables using the form variables.
eg.
Code:
$mail->Username=$_POST['email']
-
Nov 24th, 2008, 11:54 PM
#6
Thread Starter
Hyperactive Member
Re: Silly email question
I dont know what to do with the files in phpmailer.
-
Nov 25th, 2008, 12:00 AM
#7
Frenzied Member
Re: Silly email question
Just put it in a folder in your site.
then in whichever php file you need to send a mail you just say:
Code:
require_once('../phpmailer/class.phpmailer.php');
Really, just spend an hour or 2 looking at examples and stuff at codeworxtech
Really useful once you got it sorted out, and not that hard as it look.
-
Dec 15th, 2008, 06:51 AM
#8
New Member
Re: Silly email question
i have tried using this script but it falls down at the isSMTP(); line. i think thats the very first line of the script. how do i counteract this? this is the 3rd script i am using. none of which seem to work on my IIS server. i need to input a username and password of the server in order for the server to send the emails thru.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|