PHP Sign-Up/ Email Verification - php

Thanks in advance.
Below is code from PHPmailer (https://github.com/Synchro/PHPMailer) which is giving me a few problems. It works along side this PHP sign-up (http://www.codingcage.com/2015/09/login-registration-email-verification-forgot-password-php.html). I know it works other then the email because the table in the database does recieve the values. I can manually update the table and and allow myself to log-in. It does send out a Error 500 page.
function send_mail($email,$message,$subject)
{
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->AddAddress($email);
$mail->Username = "EMAIL#gmail.com";
$mail->Password = "PASSWORD";
$mail->SetFrom('robert.m.smith112#gmail.com','Coding Cage');
$mail->AddReplyTo("robert.m.smith112#gmail.com","Coding Cage");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
}

Related

PHPmailer script runs without problems but doesn't send anything

I have a really simple PHP code for sending emails. The page is loading without any errors but it doesn't seem to do anything.
also, I am new to PHP and I don't really know how to debug this stuff.
I'll really appreciate a little help (: thank you!
<?php
require_once('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure ='ssl';
$mail->Host = 'smtp.gmail.com';
$mail->port = '456';
$mail->isHtml();
$mail->Username = 'lagofbot#gmail.com';
$mail->Password = 'lago9876543s';
$mail->Subject = 'Hello';
$mail->Body = "test";
$mail->From = 'no-replay';
$mail->FromName = 'no-replay';
$mail->AddAddress('mrxvr123#gmail.com');
$mail->send();
?>
change your code like this and see if it will show you any errors
$mail = new PHPMailer();
try {
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure ='ssl';
$mail->Host = 'smtp.gmail.com';
$mail->port = '456';
$mail->isHtml();
$mail->Username = 'lagofbot#gmail.com';
$mail->Password = 'lagofbot258258#258258';
$mail->Subject = 'Hello';
$mail->Body = "test";
$mail->From = 'no-replay';
$mail->FromName = 'no-replay';
$mail->AddAddress('mrxvr123#gmail.com');
$mail->send();
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
Try with this
require __DIR__.'../phpmailer/src/PHPMailer.php'; //configure according your files
require __DIR__."./phpmailer/src/Exception.php";
require __DIR__."../phpmailer/src/SMTP.php";
$mail = new \PHPMailer\PHPMailer\PHPMailer(); // create a new object
$mail->isSMTP(); // enable SMTP
$mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->Username = ""; //GMAIL ACCOUNT EMAIL ID
$mail->Password = ""; // GMAIL ACCOUNT PASSWORD
$mail->SetFrom("",''); // FROM THIS MAIL ID & SET AS DEFINE IN SECOND PARAMETER
$mail->addAddress($email); // `TO` FIELD IN MAIL
$mail->IsHTML(true);
if (!$mail->Send()) {
return true;
} else {
return false;
}
And don't forget to enable less secure apps if you use gmail.
Hope this helps :)

Email to SMS using PHPMailer

Good Day, I found in google that you can send sms messages just by typing the recipients mobile number plus the sms gateway using phpmailer and I tested it on my mobile phone but for some reason I don't received any sms messages. This is my php code:
require($_SERVER['DOCUMENT_ROOT']."/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
// Configure smptp
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Encoding = '7bit';
// Authentication
$mail->Username = "**********#gmail.com";
$mail->Password = "******";
// Compose
$mail->Subject = "Testing";
$mail->Body = "Testing";
// Send to
$mail->AddAddress("***********#mysmart.mymobile.ph");
var_dump($mail->send()); //Send!
and here is the var_dump
I am residing in the philippines. Thanks.

PHPMailer With Yii

I am trying to send email using PHPMailer with Yii with no success. Here are my Settings:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = "mymail#gmail.com";
$mail->Password = "************";
$mail->SMTPSecure = 'ssl'
Here is my Controller Function:
$mail->IsHTML(true);
$mail->From = Yii::app()->params['adminEmail'];
$mail->FromName = empty($_POST['EmailForm']["from_name"]) ? Yii::app()->params['emailFrom'] : $_POST['EmailForm']["from_name"];
$mail->Subject = $subject;
$mail->Body = nl2br($message) . $mail->Body;
$mail->AddAddress($to);
$mail->AddCC($cc);
$mail->send();
But When I try to send an email the following error pops up:
The following email address failed myemail#gmail.com. called mail()
without being connected.
Please help me solve this!
with smtp.gmail.com i think you should use this setting:
$mail->Port = 587;
$mail->SMTPSecure = 'tls';

PHPmailer : Showing a weird text before sending a mail?

My problem is clear, PHPmailer is howing a long text before sending a mail, this is my code (function) :
function sendMail($content){
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;
$mail->Port=465; // Enable SMTP authentication
$mail->Username = 'my mail'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug=true;
$mail->From = '****';
$mail->FromName = '******';
$mail->addAddress('******');
$mail->Subject = 'subject';
$mail->Body=$content;
$mail->AltBody ='testing';
$stat=$mail->send();
}
and this is a screenshot :
http://i.imgur.com/kLrC97q.jpg
Thanks
Sorry guys, I noticed that I should turn off debugging :
$mail->SMTPDebug=false;

PhpMailer Authentication Error

I'm trying to configure email by using phpmailer and smtp but Authentication error appears.
Code below
include_once("phpmailer.php");
$mail = new PHPMailer();
$tarih = date("d.m.Y - H:i:s");
$mail->IsSMTP();
$mail->Host = "mail.golcukdh.gov.tr";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "username";
$mail->Password = "password";
$mail->IsHTML(true);
$mail->From = "email";
$mail->AddAddress("email");
$mail->Subject = "subject";
$mail->Body = "Body Part";
$mail->Send()
?>
I tried to configure this by using asp.net with these authentication information and it was successfull. But I want to use php, what is wrong ?

Categories