problems sending email to SMTP with PHPMailer

By : lamcro
Source: Stackoverflow.com
Question!

I get the following error log when trying to send a message through an Exchange server:

SMTP -> get_lines(): $data was "" 
SMTP -> get_lines(): $str is "220 mail.borschow.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Tue, 7 Apr 2009 21:56:53 -0400 " 
SMTP -> get_lines(): $data is "220 mail.borschow.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Tue, 7 Apr 2009 21:56:53 -0400 " 
SMTP -> FROM SERVER: 220 mail.borschow.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Tue, 7 Apr 2009 21:56:53 -0400 
SMTP -> get_lines(): $data was "" 
SMTP -> get_lines(): $str is "250-mail.borschow.com Hello [10.0.254.231] " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] " 
SMTP -> get_lines(): $str is "250-TURN " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN " 
SMTP -> get_lines(): $str is "250-SIZE " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE " 
SMTP -> get_lines(): $str is "250-ETRN " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN " 
SMTP -> get_lines(): $str is "250-PIPELINING " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING " 
SMTP -> get_lines(): $str is "250-DSN " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN " 
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES " 
SMTP -> get_lines(): $str is "250-8bitmime " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime " 
SMTP -> get_lines(): $str is "250-BINARYMIME " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME " 
SMTP -> get_lines(): $str is "250-CHUNKING " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING " 
SMTP -> get_lines(): $str is "250-VRFY " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY " 
SMTP -> get_lines(): $str is "250-X-LINK2STATE " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-LINK2STATE " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-LINK2STATE " 
SMTP -> get_lines(): $str is "250-XEXCH50 " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-LINK2STATE 250-XEXCH50 " 
SMTP -> get_lines(): $data was "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-LINK2STATE 250-XEXCH50 " 
SMTP -> get_lines(): $str is "250 OK " 
SMTP -> get_lines(): $data is "250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-LINK2STATE 250-XEXCH50 250 OK " 
SMTP -> FROM SERVER: 250-mail.borschow.com Hello [10.0.254.231] 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-X-LINK2STATE 250-XEXCH50 250 OK 
SMTP -> get_lines(): $data was "" 
SMTP -> get_lines(): $str is "504 5.7.4 Unrecognized authentication type. " 
SMTP -> get_lines(): $data is "504 5.7.4 Unrecognized authentication type. " 
SMTP -> ERROR: AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type. 
SMTP -> get_lines(): $data was "" 
SMTP -> get_lines(): $str is "250 2.0.0 Resetting " 
SMTP -> get_lines(): $data is "250 2.0.0 Resetting " 
SMTP -> FROM SERVER: 250 2.0.0 Resetting

Notes

  • I've tried with my assigned user/password, but the administrator said there's not even a need to use a user/password when sending. So I also tried without it, with no success.
  • I even tried with smtp.gmail.com

UPDATE (4/16/2009)

ok, I found my problem. I am using an SMTP server that permits sending messages without authentication. Therefore I removed the login and password from my code. But I forgot to set the "uses authentication" flag to false. Now it's working.

Thanks for the Help!

By : lamcro


Answers

Try adding this:

$mail->SMTPAuth = true;

$mail->SMTPSecure = "tls";

TLS is needed for many SMTP servers these days.

By : jjwdesign


Table design in LaTeX has not been made very easy. I would use tabbing rather than tabular and draw the lines manually to keep things simple. A downside is that you don't get any automatic sizing of the table cells, but since your format is fixed, I would consider it a good thing (i.e., if text overflows, you notice it and get to fix it yourself, and your table doesn't accidentally get stretched into the margins). If you use multiple tables like this in your document, try packaging the commands with \newenvironment.

\documentclass{article}
\usepackage[margin=15mm]{geometry}
\usepackage{amsmath}
\usepackage{calc}

\newlength{\tableheight}
\setlength{\tableheight}{20cm}  % how high to draw the lines of the table
\newlength{\rulethickness}
\setlength{\rulethickness}{1pt} % how thick lines to draw
\newcommand{\verticalline}{\smash{\rule[-\tableheight]{\rulethickness}{\tableheight}}}
\newlength{\myindent}
\setlength{\myindent}{3mm}      % how much to indent each column
\newlength{\leftcolumn}
\setlength{\leftcolumn}{3cm-\myindent}
\newlength{\midcolumn}
\setlength{\midcolumn}{\textwidth-3cm-5cm-\myindent-\rulethickness}
\newlength{\rightcolumn}
\setlength{\rightcolumn}{5cm-\myindent}

\begin{document}
\begin{tabbing}
  % first set the tab stops
  \hspace*{\myindent}\=\hspace{\leftcolumn}\=%
  \hspace{\myindent}\=\hspace{\midcolumn}\=%
  \hspace{\myindent}\=\hspace{\rightcolumn}\=\kill
  % then draw the lines
  \rule{\textwidth}{\rulethickness}\\[-\baselineskip]
  \smash{\rule[-\tableheight]{\textwidth}{\rulethickness}}\\[-\baselineskip]
  \verticalline\>\>\verticalline\>\>\verticalline\>\>\verticalline\\
  % Now start the table: indent the first column with \>
  \>ABS 3--2--7 
  % ... and each additional column with \>\>
  \>\> $\iint_{-\infty,-\infty}^{\infty,\infty} e^{-x^2-y^2}\, dx\,dy$ 
  \>\> 2.507 
  % End each line with \\, add e.g. [2pt] to get 2pt extra space if required
  \\[2pt]
  % here's another line:
  \>ABS 3--2--8 \>\> $\displaystyle\sum_{k=0}^n k^2$ \>\> $\frac12 n(n+1)$ \\
  % etc. Be careful not to overflow the table - there's no automatic check for that.
\end{tabbing}

\newpage % also remember to start a new page after the table

\end{document}

To change the fixed names, see this FAQ, or possibly this one if you are using babel.



Put the preferred values in a dictionary. Looking up keys in a dictionary is a O(1) operation compared to finding values in a list which is a O(n) operation, so it scales much better.

Create a sort string for each preferred value so that they are placed before the other values. For the other values the value itself will be used as sorting string so that they are actually sorted. (Using any arbitrary high value would only place them at the end of the list unsorted).

List<string> data = new List<string> {
	"E", "B", "D", "A", "C", "B", "A", "C"
};
var preferences = new Dictionary<string, string> {
	{ "A", " 01" },
	{ "B", " 02" },
	{ "C", " 03" }
};

string key;
IEnumerable<String> orderedData = data.OrderBy(
	item => preferences.TryGetValue(item, out key) ? key : item
);
By : Guffa


This video can help you solving your question :)
By: admin