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;
Related
I'm trying to use office365 smtp with phpmailer, it authenticates and it delivers sometime but sometimes it does. Not in inbox or spam. It works well with other smtp server. Here is my code:
$mail = new PHPMailer(true);
//Enable SMTP debugging.
$mail->SMTPDebug = 3;
$mail->CharSet = "utf-8";
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = $host;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
$mail->AuthType = 'LOGIN';
//Provide username and password
$mail->Username = $user;
$mail->Password = $pass;
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "STARTTLS";
//Set TCP port to connect to
$mail->Port = $port;
$mail->From = $from_email;
$mail->FromName = $from_name;
foreach($recipients as $recipients){
$mail->AddBcc($recipients);
}
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->msgHTML($message);
I use php to send email. It works perfectly, but I don't like that it outprints everything on the screen. I want this commant to remain silent. What should I do?
The command is the following:
verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '************#gmail.com'; // SMTP username
$mail->Password = '*********'; // SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
//Recipients
$mail->setFrom('*********', 'Mailer');
$mail->addAddress('**************.com');
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Want to get not';
$mail->Body = $_SESSION['nyelv'];
$mail->AltBody = $_POST['email1'];
$proba = $mail->send();
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();
}
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';
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'])."?=";