Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does phpmailer class echo texts?

when i send email it echo many unnecessary texts, i don't want these text to be printed out. how can i disable these text.

example:

SMTP -> FROM SERVER:220 mx.google.com ESMTP p1sm1037082ybn.17
SMTP -> FROM SERVER: 250-mx.google.com at your service, [xxx.xxx.xxx.xxx] 250-SIZE 35651584 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250 ENHANCEDSTATUSCODES
SMTP -> FROM SERVER:250 2.1.0 OK p1sm1037082ybn.17
SMTP -> FROM SERVER:250 2.1.5 OK p1sm1037082ybn.17
SMTP -> FROM SERVER:354 Go ahead p1sm1037082ybn.17
SMTP -> FROM SERVER:250 2.0.0 OK 1290167720 p1sm1037082ybn.17

i am using class.phpmailer.php file and using $obj.Send() method to send email. ??

thanks

like image 795
Azfar Niaz Avatar asked Nov 19 '10 12:11

Azfar Niaz


People also ask

How does PHPMailer works?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.

Is PHPMailer SMTP?

The PHP mail() function usually sends via a local mail server, typically fronted by a sendmail binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server.

Does PHPMailer work on localhost?

If the web application is built with PHP, the mail() function is used to send email from the script using PHP. But the PHP mail() function will not work in localhost.

Why is PHPMailer not working?

If you've created a PHP mail form and find it's not sending email, then it's most often due to the FROM address the form is using in its headers. A simple way to confirm if this is the case: Log in to your web server via FTP or SSH.


2 Answers

PHPMailer has a "debug" flag that you can turn off.

Depending on which version you are using, it could be named Debug or SMTPDebug. You'll know it when you see it. If necessary, look into the class file to find out the name.

Set that to false and all is well.

like image 58
Pekka Avatar answered Oct 18 '22 17:10

Pekka


By default it shouldn't generate any output. Make sure it is not wrapped in a print/echo statement/function.

A workaround could be using ob_start() at the beginning and ob_get_clean() at the end of your mailer script, so that it prevents any output from leaving the buffer.

like image 7
pestaa Avatar answered Oct 18 '22 18:10

pestaa