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 in blue as you need (I modified the sample code given on the PHPMailer homepage) ?> require("phpmailer/class.phpmailer.php"); IsSMTP(); // send via SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "username@gmail.com"; // SMTP username $mail->Password = "password"; // SMTP password $webmaster_email = "username@doamin.com"; //Reply to this email ID $email="username@domain.com"; // 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"; } ?> Code (markup): 5 Open the file class.smtp.php in phpmailer directory 6 Paste this 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. $mail->Username=$_POST['email']
I have used this.. its just uses google SMTP server nothing else... its uses PHPmailer which is certified project of sourceforge
I am a n00b to php. Can you explain in more detail how I could use this in a form. Maybe give me a quick example. I appreciate it. Thank you very much.
This in no way would bypass the relay issues for bulk mail. I have used a similar script and it works. However, you will hit a 200 to 500 relay limit. I do have a question relating to this topic though.... Is there a way to create a mailbox in PHP (and delete it). I was hoping to do this programmatically rather than in Simple Control Panel (installed on the dedicated server provided by GoDaddy). Regards, boxcar
it gives the error Fatal error: Call to undefined function IsSMTP() in D:\wamp\www\email.php on line 3 i put email.php outside the folder phpmailer.
The call to that must be replaced with the following: $mail = new PHPMailer(); $mail->IsSMTP(); but you've probably figured this out in the past year or so. Ciao.
Used above mentioned script to send mails via gmail using PHP - I got a mail from gmail support regarding a suspicious activity on my account. Please let me know if there are any changes to be made to this code so that I dont face such security issue. Thanks!