Note that there are some explanatory texts on larger screens.

plurals
  1. POphp send email using gmail smtp
    primarykey
    data
    text
    <p>I am trying to send email by using Gmail (maybe even Yahoo SMTP ) , I have the following code</p> <pre><code>require("class.phpmailer.php"); //ini_set("SMTP","smtp.google.com" ); $smtp=$_GET["smtp"]; $youremail= $_GET["youremail"]; $emailpassword=$_GET["emailpassword"]; $companyemail=$_GET["companyemail"]; $messagetitle= $_GET["messagetitle"]; $messagetext=$_GET["messagetext"]; echo "_GET variables dump" ; var_dump($smtp); var_dump($youremail); var_dump($emailpassword); var_dump($companyemail); var_dump($messagetitle); var_dump($messagetext); //this is a path to PHP mailer class you have dowloaded //include("class.phpmailer.php"); $emailChunks = explode(",", $companyemail); for($i = 0; $i &lt; count($emailChunks); $i++){ // echo "Piece $i = &lt;br /&gt;"; $mail = new PHPMailer(); $mail-&gt;IsSMTP(); $mail-&gt;SMTPDebug = 1; // errors and messages //$mail-&gt;SMTPSecure = "tls"; // sets the prefix to the servier $mail-&gt;SMTPSecure = "ssl"; $mail-&gt;Port = 587; $mail-&gt;Host = $smtp; $mail-&gt;SMTPAuth = true; // turn on SMTP authentication $mail-&gt;Username = $youremail; // SMTP username $mail-&gt;Password = $emailpassword; // SMTP password $mail-&gt;From = $youremail; //do NOT fake header. $mail-&gt;FromName = $youremail; $adr=$emailChunks[$i]; $mail-&gt;AddAddress($adr); // Email on which you want to send mail $mail-&gt;AddReplyTo($emailpassword, "Reply to"); //optional $mail-&gt;IsHTML(true); $mail-&gt;Subject = $messagetitle; $mail-&gt;Body = $messagetext; echo "mail variable dump" ; var_dump($mail); if(!$mail-&gt;Send()) { echo $mail-&gt;ErrorInfo; }else{ echo "email was sent"; } } </code></pre> <p>When I call the code - I use var_dump for debugging purpose I get </p> <pre><code>ALL EMAIL MESSAGES HAVE BEEN WITH STATUS :_GET variables dumpstring(14) "smtp.gmail.com" string(18) "me@gmail.com" string(8) "mypass" string(18) "sendTo@yahoo.com" string(2) "message subject" string(6) "message" Invalid address: mypassmail variable dumpobject(PHPMailer)#1 (53) { ["Priority"]=&gt; int(3) ["CharSet"]=&gt; string(10) "iso-8859-1" ["ContentType"]=&gt; string(9) "text/html" ["Encoding"]=&gt; string(4) "8bit" ["ErrorInfo"]=&gt; string(25) "Invalid address: mypass" ["From"]=&gt; string(18) "me@gmail.com" ["FromName"]=&gt; string(18) "me@gmail.com" ["Sender"]=&gt; string(0) "" ["Subject"]=&gt; string(2) "ja" ["Body"]=&gt; string(6) "message" ["AltBody"]=&gt; string(0) "" ["WordWrap"]=&gt; int(0) ["Mailer"]=&gt; string(4) "smtp" ["Sendmail"]=&gt; string(18) "/usr/sbin/sendmail" ["PluginDir"]=&gt; string(0) "" ["ConfirmReadingTo"]=&gt; string(0) "" ["Hostname"]=&gt; string(0) "" ["MessageID"]=&gt; string(0) "" ["Host"]=&gt; string(14) "smtp.gmail.com" ["Port"]=&gt; int(587) ["Helo"]=&gt; string(0) "" ["SMTPSecure"]=&gt; string(3) "ssl" ["SMTPAuth"]=&gt; bool(true) ["Username"]=&gt; string(18) "me@gmail.com" ["Password"]=&gt; string(8) "mypass" ["Timeout"]=&gt; int(10) ["SMTPDebug"]=&gt; int(1) ["SMTPKeepAlive"]=&gt; bool(false) ["SingleTo"]=&gt; bool(false) ["SingleToArray"]=&gt; array(0) { } ["LE"]=&gt; string(1) " " ["DKIM_selector"]=&gt; string(9) "phpmailer" ["DKIM_identity"]=&gt; string(0) "" ["DKIM_domain"]=&gt; string(0) "" ["DKIM_private"]=&gt; string(0) "" ["action_function"]=&gt; string(0) "" ["Version"]=&gt; string(3) "5.1" ["smtp:private"]=&gt; NULL ["to:private"]=&gt; array(1) { [0]=&gt; array(2) { [0]=&gt; string(18) "sendTo@yahoo.com" [1]=&gt; string(0) "" } } ["cc:private"]=&gt; array(0) { } ["bcc:private"]=&gt; array(0) { } ["ReplyTo:private"]=&gt; array(0) { } ["all_recipients:private"]=&gt; array(1) { ["sendTo@yahoo.com"]=&gt; bool(true) } ["attachment:private"]=&gt; array(0) { } ["CustomHeader:private"]=&gt; array(0) { } ["message_type:private"]=&gt; string(0) "" ["boundary:private"]=&gt; array(0) { } ["language:protected"]=&gt; array(17) { ["provide_address"]=&gt; string(54) "You must provide at least one recipient email address." ["mailer_not_supported"]=&gt; string(25) " mailer is not supported." ["execute"]=&gt; string(19) "Could not execute: " ["instantiate"]=&gt; string(36) "Could not instantiate mail function." ["authenticate"]=&gt; string(35) "SMTP Error: Could not authenticate." ["from_failed"]=&gt; string(35) "The following From address failed: " ["recipients_failed"]=&gt; string(45) "SMTP Error: The following recipients failed: " ["data_not_accepted"]=&gt; string(30) "SMTP Error: Data not accepted." ["connect_host"]=&gt; string(43) "SMTP Error: Could not connect to SMTP host." ["file_access"]=&gt; string(23) "Could not access file: " ["file_open"]=&gt; string(33) "File Error: Could not open file: " ["encoding"]=&gt; string(18) "Unknown encoding: " ["signing"]=&gt; string(15) "Signing Error: " ["smtp_error"]=&gt; string(19) "SMTP server error: " ["empty_message"]=&gt; string(18) "Message body empty" ["invalid_address"]=&gt; string(15) "Invalid address" ["variable_set"]=&gt; string(30) "Cannot set or reset variable: " } ["error_count:private"]=&gt; int(1) ["sign_cert_file:private"]=&gt; string(0) "" ["sign_key_file:private"]=&gt; string(0) "" ["sign_key_pass:private"]=&gt; string(0) "" ["exceptions:private"]=&gt; bool(false) } SMTP -&gt; ERROR: Failed to connect to server: Connection timed out (110) &lt;br /&gt;SMTP Error: Could not connect to SMTP host. SMTP Error: Could not connect to SMTP host. </code></pre> <p>And the email send fails !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload