14492

Can not send mail through PHPMailer

This is my php code

require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.gmail.com"; // SMTP server $mail->From = "example@gmail.com"; $mail->AddAddress("example@yahoo.com"); $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; }

My php.ini has this mail configuration [mail function]

SMTP = smtp.gmail.com smtp_port = 465 sendmail_from =example@gmail.com

My error is

The following From address failed: example@gmail.com Message was not sent.Mailer error: The following From address failed: example@gmail.com SMTP server error: 5.7.0 Must issue a STARTTLS command first. i1sm13250552pbv.49

please help me.thanks in advance......

Answer1:

smtp.gmail.com requires that you use SSL and port 587 or 465.

Answer2:

firstly be sure you have the last version of phpmailer()

download it from https://github.com/PHPMailer/PHPMailer

open class.phpmailer.php by php editor

replace all "HELO" words to "EHLO"

EHLO (not HELO) must be given by client before AUTH. (FOR GOOGLE MAIL)

it will be solved.

Answer3:

try phpgmailer once http://www.thedanglybits.com/2006/10/13/update-send-email-with-php-and-gmail-hosted-for-your-domain/

Answer4:

Change your host to

ssl://smtp.gmail.com:465

Recommend

  • How to make QLabel expand width geometry to accommodate text
  • PDOStatement::fetch occasionally returns false, but errorInfo() is empty
  • AS3 TextField AntiAliasType breaks WordWrap
  • After creating table it shows this Array ( [0] => 00000 [1] => [2] => )
  • How to use PHPMailer without composer?
  • PHP to connect to Hotmail to send email?
  • Symfony2 Service Container - does get() return objects by reference or copy?
  • Websocket error by closing a page via browser: “An established connection was aborted by the softwar
  • How to configure Joomla 1.7 SMTP email with a google apps email address
  • Enabling domxml in php
  • Change of MySQL database location not working
  • Sending email through PHP mail function not working for long emails
  • Changing MySQL charset to UTF8 on linux so it will work with JDBC
  • Error authenticating using LinkedIn iOS SDK
  • PHP - sending email with attachment does not show message content
  • Problems installing Yesod for Haskell
  • Spring Cloud Microservice Architecture Confusion
  • Unable to install Git-core+svn by MacPorts
  • Stop Bash Script if Hive Fails
  • Install PHP intl extension on MacOS
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Play WS (2.2.1): post/put large request
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • ilmerge with a PFX file
  • How can I send an e-mail from a vbs script
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Updating server-side rendering client-side
  • Display Images one by one with next and previous functionality
  • Upload files with Ajax and Jquery
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How to pass list parameters for each object using Spring MVC?
  • Is there a mandatory requirement to switch app.yaml?
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • sending mail using smtp is too slow
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS