-1

Is there something I'm missing? I've searched high, and low, and I'm not sure what's wrong with my code. Also is it that I'm using public, rather than mail?

    <?php
require_once('phpmailer.php');
class Mail extends PhpMailer
{
    // Set default variables for all new objects
    public $mail     = IsSMTP;   
    public $From     = 'register@lolvoid.net23.net';
    public $FromName = SITETITLE;
    public $Host     = 'smtp.gmail.com';
    public $port     = 587;
    public $Mailer   = 'smtp';
    public $SMTPAuth = true;
    public $Username = 'email@gmail.com';
    public $Password = 'password';
    public $SMTPSecure = 'tls';
    public $WordWrap = 75;

    public function subject($subject)
    {
        $this->Subject = $subject;
    }

    public function body($body)
    {
        $this->Body = $body;
    }

    public function send()
    {
        $this->AltBody = strip_tags(stripslashes($this->Body))."\n\n";
        $this->AltBody = str_replace("&nbsp;", "\n\n", $this->AltBody);
        return parent::send();
    }
}

This is my current code, and the issue hasn't been resolved. Any new ideas?

Jayy
  • 49
  • 8

3 Answers3

0

Most probably a port.

 public $port     = '4587';

if you tried configuring your SMTP server on port 465 (with SSL/TLS) and port 587 (with STARTTLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL/TLS).

Apple Mail users: At times, Mail may misinterpret your SMTP server settings. If you currently have 'smtp.gmail.com:username@gmail.com' in the 'Outgoing Mail Server:' field of your settings, please try changing the field to 'smtp.gmail.com' and saving your settings.

https://support.google.com/mail/answer/78775?hl=en

You mixed 465 and 587 ports.

If it still does not work, you can try debugging connection. See PHPMailer only sends email when SMTPDebug = true for example.

Also, from documentation:

/**
 * SMTP class debug output mode.
 * Debug output level.
 * Options:
 * * `0` No output
 * * `1` Commands
 * * `2` Data and commands
 * * `3` As 2 plus connection status
 * * `4` Low-level data output
 * @var integer
 * @see SMTP::$do_debug
 */
public $SMTPDebug = 0;

Use it to find out what problem may be. It will tell you where it stops.

Community
  • 1
  • 1
Grzegorz
  • 3,538
  • 4
  • 29
  • 47
0

Port should be 587 instead of 4587.

Here are the default Gmail SMTP settings;

  • Gmail SMTP server address: smtp.gmail.com
  • Gmail SMTP username: Your full Gmail address (e.g. yourusername@gmail.com)
  • Gmail SMTP password: Your Gmail password
  • Gmail SMTP port (TLS): 587
  • Gmail SMTP port (SSL): 465
  • Gmail SMTP TLS/SSL required: yes

and could you please change the line

public $mail = 'IsSMTP()'

with the following:

public $mail = IsSMTP();
Kaan Burak Sener
  • 974
  • 10
  • 19
0

Change port to secured one for SMTP: 465

Hardik V.
  • 374
  • 2
  • 9