• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2397
  • Last Modified:

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

0
rgb192
Asked:
rgb192
  • 4
1 Solution
 
Richard QuadlingSenior Software DeverloperCommented:
There should be no need to change the parameters.

You send to GMail using the same mechanism as any other SMTP server.

I would use gmail-smtp-in.l.google.com as the server and port 25 as normal.

Port 587 is submission      587/tcp    Submission
Port 465 is urd             465/tcp    URL Rendesvous Directory for SSM

(From http://www.iana.org/assignments/port-numbers)


0
 
Richard QuadlingSenior Software DeverloperCommented:
Also, you've commented out the send() command, so maybe that's why it's not working!?
0
 
Richard QuadlingSenior Software DeverloperCommented:
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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Richard QuadlingSenior Software DeverloperCommented:
Profya, thanks for the link. http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_22580578.html#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).

0
 
rgb192Author Commented:
works
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now