mokalovesoulmate mokalovesoulmate - 12 days ago 5
PHP Question

Timeout when calling $mail->anyparameter with PHPMailer

as subject, I am trying to sending email with PHPMailer. But strangely, examples from PHPMailer only works on XAMPP Windows but not XAMPP Linux. I did not modify complex settings, the settings I changed from XAMPP Linux is only enabling openssl.

I am trying to execute basic code below, it works only for XAMPP Windows but not XAMPP Linux. The script were timeout each time the php process the line contains


require_once "phpmailer/class.phpmailer.php";
$mail = new PHPMailer;

$mail->AddAddress("email address", "name");
$mail->SetFrom("email address", "name");
$mail->WordWrap = 50;
$mail->Subject = "Subject";
$mail->Body = "<p>HTML Test</p>";

Timeout message:

Fatal error: Maximum execution time of 30 seconds exceeded in /opt/lampp/htdocs/phpmailertest/phpmailer/class.phpmailer.php on line 767

Line 767 of class.phpmailer.php:

return (boolean)preg_match('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address);

Here is my details:

  • Ubuntu 12.10 desktop without LAMP component, only XAMPP for Linux

  • XAMPP version 1.8.1 (definitely latest version)

  • PHPMailer from version master.

Looks like something is wrong with my XAMPP Linux but I cant trace the problem.

Any help?



I had the exact same problem. I fixed it with a dirty hack. Replace the function (Starting with public static function ValidateAddress($address) {) with this:

public static function ValidateAddress($address) {
    return true;

This will validate any address you supply, any!

You should check addresses yourself before using them with PHPMailer. I don't know what could happen if you don't, just check the addresses.