Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

php htmlMimeMail5()




want to use

$mail = new htmlMimeMail5();
to send email


i am editing php but changing the email to gmail

is this being sent on port 587
i saw ehlo on telnet as a command
      $mail->setSMTPParams('smtp.gmail.com', '587', 'EHLO', TRUE, 'gmail@gmail.com', 'password');

how does htmlmimemail5() differ from smtp

also do i have to use port 587
because i know that gmail uses port 465



function recordPHPerror($error_number, $error_string, $error_file, $error_line, $error_context) {
	$textbody = "
		<pre>
		URL: ".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."
		Error Number: $error_number
		Error Message: $error_string
		Error Time: ".$_SERVER['REQUEST_TIME']."
		File: $error_file
		Line: $error_line
		Error Backtrace:

		".var_export(debug_backtrace(), true)."

		Error Context:

		".var_export($error_context, true)."</pre>";
	$htmlbody = $textbody;

	$mail = new htmlMimeMail5();
    $mail->setFrom("gmail@gmail.com");
    $mail->setSubject("OW Error - ".md5($error_number.$error_string.$error_file.$error_line));
    $mail->setPriority('high');
    $mail->setText($textbody);
    $mail->setHTML($htmlbody);
	$mail->setSMTPParams('smtp.gmail.com', '587', 'EHLO', TRUE, 'gmail@gmail.com', 'password');
//	$mail->send(array(""),"smtp");

	return false;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, you've commented out the send() command, so maybe that's why it's not working!?
Edit the code below to use appropriate email addresses.
<?php
// Prepare the email handler.
$o_Mail = new htmlMimeMail5();

$o_Mail->setHeadCharset('UTF-8');
$o_Mail->setHTMLCharset('UTF-8');
$o_Mail->setTextCharset('UTF-8');

$o_Mail->setText('You should not be able to read this message.\n\nIf you can, please contact your system administrator and ask for an email application capable of reading HTML/MIME Emails.');
$o_Mail->setHTML('<html>
<head>
 <title>GMail message using htmlMimeMail5.</title>
</head>
<body>
 <div>
  <h1>GMail message using htmlMimeMail5.</h1>
  <hr />
 </div>
</body>
</html>');
$o_Mail->setSubject('GMail message using htmlMimeMail5.');
$o_Mail->setFrom('RQuadling@e-e.com');

// Get the SMTP server for GMail.com
getmxrr('GMail.com', $a_MXHosts, $a_Weights);

// Sort the hosts so that the lowest weight server is first.
$a_MXHosts = array_combine($a_MXHosts, $a_Weights);
asort($a_MXHosts);

// Show the hosts.
print_r($a_MXHosts);

// Send email to each host until successful.
$b_Sent = False;
foreach($a_MXHosts as $s_Host => $i_Weight)
	{
	echo "Attempting to send to $s_Host with weight of $i_Weight", PHP_EOL;
	$o_Mail->setSMTPParams($s_Host);
	if ($b_Sent = $o_Mail->send(array('"Richard Quadling" <RQuadling@xxxxxxx.com>'), 'smtp'))
		{
		break;
		}
	}

// Did we send?
if (!$b_Sent)
	{
	echo 'Failed to send email to any of the GMail hosts.';
	exit (1);
	}
echo 'Successfully sent email to GMail.';

Open in new window

Profya, thanks for the link. https://www.experts-exchange.com/questions/22580578/Why-is-becoming-very-slow-when-I-using-php-move-upload-function.html?anchorAnswerId=19140020#a19140020 specifically.

More or less repeating what I said already.

The only real change is that getmxrr() is now available on Windows in PHP (it wasn't when I write the answer back in March 2007).

Avatar of rgb192

ASKER

works