Email to SMS using PHPMailer - php

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.

Related

I recently trying to use mail system but It doesn't work like before

I've once successfully build up my mailing system, but at that time I didn't understand what happen inside of it.
Now, I'm re-building same system, using PHPMailer, and now Gateway Timeout error happens. Please help me to fix my code down here.. What I did is just copy the example and put my account and password.
$Mail = new PHPMailer;
$Mail->SMTPDebug = 2;
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server
$Mail->SMTPDebug = 2; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "tls"; //Secure conection
$Mail->Port = 587; // set the SMTP port
$Mail->Username = 'myid#gmail.com'; // SMTP account username
$Mail->Password = 'mypassword'; // SMTP account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = 'SUB';
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'gatesplan#gmail.com';
$Mail->FromName = 'FROM NAME';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->AddAddress($email); // To:
$Mail->isHTML(TRUE);
$Mail->Body = "Hi";
$Mail->AltBody = "Hi";
$Mail->Send();
$Mail->SmtpClose();

PHP Sign-Up/ Email Verification

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();
}

PHP mailer not sending mails to particular groups

Am using PHP mailer for sending emails.For individual users and for some groups i am able to send mails but for some other groups the mails are not going.Am using Microsoft exchange server for the mails.And there are no errors shown in the log file in the host.
PHP mailer code:
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'email.domain.com';
$mail->SMTPAuth = true;
$mail->Username = 'username#domain.com';
$mail->Password = '********';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('username#domain.com');
$addresses = 'Recipients#domain.com';
$mail->isHTML(true);
Thanks in advance.

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 & in subject coming in as &

I am sending emails using PHPMailer and through my gmail account with SMTP. It all works except when there is an & in the subject, then in my inbox the subject has &
Any way to make this not happen? I've tried setting the charset and encoding the subject.
My code is below
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = false;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "myusername#gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->SetFrom('from#somesite.com', 'From Person');
$mail->AddReplyTo("from#somesite.com", "From Person");
$mail->Subject = 'An example with a & in the middle';
$mail->MsgHTML('Some text to send');
$mail->AddAddress('myusername#gmail.com');
$mail->Send()
Thank You
Try using this code, let me know if it helps.
$mail->Subject = "=?UTF-8?B?".base64_encode($_POST['subject'])."?=";

Categories