473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Sending mail using PhpMailer

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4. <?php
  5.  
  6. //this is a path to PHP mailer class you have dowloaded
  7.  
  8. include("class.phpmailer.php");
  9.  
  10. $mail = new PHPMailer();
  11.  
  12. $mail->IsSMTP(); // set mailer to use SMTP
  13.  
  14. $mail->Host = "smtp.gmail.com"; // specify main and backup server
  15.  
  16. $mail->SMTPAuth = true; // turn on SMTP authentication
  17.  
  18. $mail->Username = "hariniamjs@gmail.com"; // SMTP username
  19.  
  20. $mail->Password = "xxx"; // SMTP password
  21.  
  22. $mail->From = "harini@gmail.com"; //do NOT fake header.
  23.  
  24. $mail->FromName = "MailMan";
  25.  
  26. $mail->AddAddress("harini@gmail.com"); // Email on which you want to send mail
  27.  
  28. $mail->AddReplyTo("hariniamjs@gmail.com", "Support and Help"); //optional
  29.  
  30. $mail->IsHTML(true);
  31.  
  32. $mail->Subject = "Just a Test";
  33.  
  34. $mail->Body = "Hello. I am testing <b>PHP Mailer.</b>";
  35.  
  36. if(!$mail->Send())
  37.  
  38. {
  39.  
  40. echo $mail->ErrorInfo;
  41.  
  42. }else{
  43.  
  44. echo "email was sent";
  45.  
  46. }
  47.  
  48. ?>
  49.  
  50.  
  51.  
In the PhpMailer class i use the above script to access the functionality but it give the error as "SMTP Error: Could not authenticate. SMTP Error: Could not authenticate".

Please help me...

What can i do to clear this error?

when i give $mail->SMTPDebug = 2; in my coding it give info abt error as

SMTP -> FROM SERVER:220 mx.google.com ESMTP nw9sm12423499pbb.42
SMTP -> FROM SERVER: 250-mx.google.com at your service, [14.194.185.224] 250-SIZE 35882577 250-8BITMIME 250 ENHANCEDSTATUSCODES
SMTP -> ERROR: AUTH not accepted from server: 530 5.7.0 Must issue a STARTTLS command first. nw9sm12423499pbb.42
SMTP -> FROM SERVER:250 2.1.5 Flushed nw9sm12423499pbb.42
Jan 13 '13 #1
0 1691

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: vishal | last post by:
i am getting following error. Warning: mail() : Failed to connect to mailserver at "smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in...
1
by: Hari | last post by:
Hi all! I am trying to send mail using outlook in my web application. i am using Outlook Express. Actually i am saving it in DRAFTS folder instead of sending it. My system are in network. I hard...
3
by: at | last post by:
Hi, I need to test a mail function through my IPS, who doesn't allow sending mail without a password. Where do I specify this password? In php.ini I can specify SMTP and sender, but apparently...
2
by: ינון אזרד | last post by:
Hi. I tring to send a email. I wrote the following lines: (Imports System.Net.Mail) Dim MailMsg As New MailMessage Dim WithEvents MailSmtp As New SmtpClient MailSmtp.Host = gmail.smtp.com...
2
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name)...
0
debasisdas
by: debasisdas | last post by:
The follwing sample code uses predefined package UTL_SMTP to send mail. This package was first available in the version 8.1.7 . create or replace procedure sendmail(sender varchar2,recipient...
1
by: dilip1076 | last post by:
I developed an application to send mail using smtpClient. my mail server is mail.brm.edu.in. I am passing this as "smtp.mail.brm.edu.in" but i'm unable to send. It shows failure sending mail. plz...
4
by: Kapil Choubisa | last post by:
Hello all I am using smtp for sending mail. it ask the smtp host name. that is smtp.Host = "smtp.gmail.com"; what is for yahoo/rediff/hotmail is there any one for globle mail systems.
0
by: m103069 | last post by:
Dear Friend, I am developing an application where i am using System.Net.Mail Namespace. its working fine if mail sending through hosting server but i am not able to send mail using lotus note...
4
KeredDrahcir
by: KeredDrahcir | last post by:
I'm trying to send an E-mail using PHPMailer and although everything look okay, it's not coming through. Can anyone help? I'm posting my information from a form. require_once...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.