Setting up Phpmailer for Newsletter

Asked

Viewed 242 times

0

I am using Wordpress and in it, the plugin Sendpress for sending the Newsletter. The configuration is made from the file Phpmailer.

The problem is that it is only sending to emails that are within my domain. When sending to an external email (gmail, outlook, yahoo and etc) the same does not work.

From what I understand, the only piece of code I have to modify is the one below:

I add the sending emai, the "Sender", host -> mail.meudominio.com.br``and the port that is 587.

Where am I missing? There is another chunk and file I should modify??

class SendPress_PHPMailer
{
/**
 * The PHPMailer Version number.
 * @type string
 */
public $Version = '5.2.10';

/**
 * Email priority.
 * Options: 1 = High, 3 = Normal, 5 = low.
 * @type integer
 */
public $Priority = 3;

/**
 * The character set of the message.
 * @type string
 */
public $CharSet = 'utf8';

/**
 * The MIME Content-type of the message.
 * @type string
 */
public $ContentType = 'text/plain';

/**
 * The message encoding.
 * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
 * @type string
 */
public $Encoding = '8bit';

/**
 * Holds the most recent mailer error message.
 * @type string
 */
public $ErrorInfo = '';

/**
 * The From email address for the message.
 * @type string
 */
public $From = '[email protected]';  

/**
 * The From name of the message.
 * @type string
 */
public $FromName = 'Eu';

/**
 * The Sender email (Return-Path) of the message.
 * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
 * @type string
 */
public $Sender = '[email protected]';

/**
 * The Return-Path of the message.
 * If empty, it will be set to either From or Sender.
 * @type string
 * @deprecated Email senders should never set a return-path header;
 * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
 * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
 */
public $ReturnPath = '';

/**
 * The Subject of the message.
 * @type string
 */
public $Subject = '';

/**
 * An HTML or plain text message body.
 * If HTML then call isHTML(true).
 * @type string
 */
public $Body = '';

/**
 * The plain-text message body.
 * This body can be read by mail clients that do not have HTML email
 * capability such as mutt & Eudora.
 * Clients that can read HTML will view the normal Body.
 * @type string
 */
public $AltBody = '';

/**
 * An iCal message part body.
 * Only supported in simple alt or alt_inline message types
 * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
 * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
 * @link http://kigkonsult.se/iCalcreator/
 * @type string
 */
public $Ical = '';

/**
 * The complete compiled MIME message body.
 * @access protected
 * @type string
 */
protected $MIMEBody = '';

/**
 * The complete compiled MIME message headers.
 * @type string
 * @access protected
 */
protected $MIMEHeader = '';

/**
 * Extra headers that createHeader() doesn't fold in.
 * @type string
 * @access protected
 */
protected $mailHeader = '';

/**
 * Word-wrap the message body to this number of chars.
 * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
 * @type integer
 */
public $WordWrap = 0;

/**
 * Which method to use to send mail.
 * Options: "mail", "sendmail", or "smtp".
 * @type string
 */
public $Mailer = 'mail';

/**
 * The path to the sendmail program.
 * @type string
 */
public $Sendmail = '/usr/sbin/sendmail';

/**
 * Whether mail() uses a fully sendmail-compatible MTA.
 * One which supports sendmail's "-oi -f" options.
 * @type boolean
 */
public $UseSendmailOptions = true;

/**
 * Path to PHPMailer plugins.
 * Useful if the SMTP class is not in the PHP include path.
 * @type string
 * @deprecated Should not be needed now there is an autoloader.
 */
public $PluginDir = '';

/**
 * The email address that a reading confirmation should be sent to.
 * @type string
 */
public $ConfirmReadingTo = '';

/**
 * The hostname to use in Message-Id and Received headers
 * and as default HELO string.
 * If empty, the value returned
 * by SERVER_NAME is used or 'localhost.localdomain'.
 * @type string
 */
public $Hostname = '';

/**
 * An ID to be used in the Message-Id header.
 * If empty, a unique id will be generated.
 * @type string
 */
public $MessageID = '';

/**
 * The message Date to be used in the Date header.
 * If empty, the current date will be added.
 * @type string
 */
public $MessageDate = '';

/**
 * SMTP hosts.
 * Either a single hostname or multiple semicolon-delimited hostnames.
 * You can also specify a different port
 * for each host by using this format: [hostname:port]
 * (e.g. "smtp1.example.com:25;smtp2.example.com").
 * You can also specify encryption type, for example:
 * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
 * Hosts will be tried in order.
 * @type string
 */
public $Host = 'mail.meudominio.com.br';

/**
 * The default SMTP server port.
 * @type integer
 * @TODO Why is this needed when the SMTP class takes care of it?
 */
public $Port = 587;

/**
 * The SMTP HELO of the message.
 * Default is $Hostname.
 * @type string
 * @see PHPMailer::$Hostname
 */
public $Helo = '';

/**
 * What kind of encryption to use on the SMTP connection.
 * Options: '', 'ssl' or 'tls'
 * @type string
 */
public $SMTPSecure = '';

/**
 * Whether to enable TLS encryption automatically if a server supports it,
 * even if `SMTPSecure` is not set to 'tls'.
 * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
 * @type boolean
 */
public $SMTPAutoTLS = true;       

NOTE: I tried to use another newsletter plugin, just put my email, name, SMTP put as localhost and disabled the security protocol (ssl, tls) and also login and password authentication. Just doing this worked! I tried to do the same in this code but without success, someone could help me??

(Why don’t I use this and drop Sendpress?? Because Sendpress has more features and no subscript limit)

  • The SPF, in DNS, you are allowing sending on behalf of your domain to the IP of this server?

  • My SPF is directed to Locaweb, which is the contracted server. It has no ip range, it’s just spf.locaweb.com.br

  • At Locaweb you can change it. Changes including your ip.

  • So instead of ip I added this path. It was the recommendation I received from Locaweb itself. This may be causing some conflict?

  • http://wiki.locaweb.com/pt-br/Entrada_TXT

  • I get it. Well, is that what might be causing this conflict? From sending emails locally but to external emails not??

  • If memory serves, PHP Mailer uses sendmail by default. This is your case?

  • Yes, sendmail is mentioned in the code

  • Then, adding my IP to the SPF will make it "free" to send emails to any domain in the form of newsletter?

  • Try sending with sendmail without php to see if e-mal is enough. If it is not enough, you have to review the sendmail configuration.

  • In fact the target mail server will check that your server can send email as if it were your domain.

  • I created an answer to not turn comments into chat.

Show 7 more comments

1 answer

1

First you need to specify the SPF of DNS. The Locaweb indicates this change: Locaweb Input TXT. SPF tells the target server that your server can send emails through the domain.

Normally, PHP Mailer uses sendmail by default. If this is the case, it is best that you do a direct manual test through the console, isolating the problem. Locaweb also has a tutorial about it. If it fails, it will be time to waste some time reconfiguring the sendmail.

  • I added my IP to the SPF TXT. However, I think the problem is in the configuration of sendpress, as I said I tried to use another plugin and it worked. I left the section of phpmailer where I made some settings.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.