SMTP codes

SMTP de la engl. Simple Mail Transfer Protocol

 

Reply codes in numerical order
Code Meaning
200 (nonstandard success response, see rfc876)
211 System status, or system help reply
214 Help message
220 Service ready
221 Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to
354 Start mail input; end with .
421 Service not available, closing transmission channel
450 Requested mail action not taken: mailbox unavailable
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
521 does not accept mail (see rfc1846)
530 Access denied (???a Sendmailism)
550 Requested action not taken: mailbox unavailable
551 User not local; please try
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
554 Transaction failed

Reply codes grouped by command
Command Code Description
connect
220 Service ready
421 Service not available, closing transmission channel
HELO
250 Requested mail action okay, completed
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
504 Command parameter not implemented
521 does not accept mail [rfc1846]
421 Service not available, closing transmission channel
EHLO
250 Requested mail action okay, completed
550 Not implemented
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
504 Command parameter not implemented
421 Service not available, closing transmission channel
MAIL
250 Requested mail action okay, completed
552 Requested mail action aborted: exceeded storage allocation
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
421 Service not available, closing transmission channel
RCPT
250 Requested mail action okay, completed
251 User not local; will forward to
550 Requested action not taken: mailbox unavailable
551 User not local; please try
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
450 Requested mail action not taken: mailbox unavailable
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
503 Bad sequence of commands
521 does not accept mail [rfc1846]
421 Service not available, closing transmission channel
DATA
354 Start mail input; end with .
451 Requested action aborted: local error in processing
554 Transaction failed
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
503 Bad sequence of commands
421 Service not available, closing transmission channel
received data
250 Requested mail action okay, completed
552 Requested mail action aborted: exceeded storage allocation
554 Transaction failed
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
RSET
200 (nonstandard success response, see rfc876)
250 Requested mail action okay, completed
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
504 Command parameter not implemented
421 Service not available, closing transmission channel
SEND
250 Requested mail action okay, completed
552 Requested mail action aborted: exceeded storage allocation
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
421 Service not available, closing transmission channel
SOML
250 Requested mail action okay, completed
552 Requested mail action aborted: exceeded storage allocation
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
421 Service not available, closing transmission channel
SAML
250 Requested mail action okay, completed
552 Requested mail action aborted: exceeded storage allocation
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient system storage
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
421 Service not available, closing transmission channel
VRFY
250 Requested mail action okay, completed
251 User not local; will forward to
550 Requested action not taken: mailbox unavailable
551 User not local; please try
553 Requested action not taken: mailbox name not allowed
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
504 Command parameter not implemented
421 Service not available, closing transmission channel
EXPN
250 Requested mail action okay, completed
550 Requested action not taken: mailbox unavailable
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
504 Command parameter not implemented
421 Service not available, closing transmission channel
HELP
211 System status, or system help reply
214 Help message
500 Syntax error, command unrecognised
501 Syntax error in parameters or arguments
502 Command not implemented
504 Command parameter not implemented
421 Service not available, closing transmission channel
NOOP
200 (nonstandard success response, see rfc876)
250 Requested mail action okay, completed
500 Syntax error, command unrecognised
421 Service not available, closing transmission channel
QUIT
221 Service closing transmission channel
500 Syntax error, command unrecognised
TURN
250 Requested mail action okay, completed
502 Command not implemented
500 Syntax error, command unrecognised
503 Bad sequence of commands

Enum-urile in C

Definiție: Enum-urile sunt un set de constante încapsulate sub forma unui tip de date care se pot definii de către utilizator cu valori predefinite sau cu valori implicite. Enum-uri cu valori predefinit au valorile setate explicit de către programator. Se poate vedea în exemplele de mai jos cum se declara și cum se poate folosi.


typedef enum
{
ZERO = 42,
UNU = 13
} MyEnumType;

typedef enum
{
FALSE = 0xFFU,
TRUE = 0x00
} BooleanType;

int main()
{
BooleanType retValue;

retValue = TRUE;
printf("%d",retValue);

retValue = FALSE;
printf("%d",retValue);


return 0;
}

Enum-uri cu valori implicite au valorile stabilite de către compilator în ordine crescătoare începînd de la zero.



typedef enum
{
FALSE,
TRUE
} BooleanType;


typedef enum
{
ZERO,
UNU,
DOI,
TREI,
PATRU,
CINCI,
SASE,
SAPTE,
OPT,
NOUA,
A,
B,
C,
D,
E,
F
} Baza16Type;

Aceste structuri de date sunt foarte utile pentru că datele sunt organizate, practic fiecare număr poate însemna ceva. Există totuși o problemă majoră când vine vorba de compilatoare diferite și alocarea memoriei pentru aceste variabile. Aceeaşi variabilă poate avea dimensiuni diferite pentru compilatoare diferite. În schimb pentru programarea sub windows enum-urile sunt foarte des folosite. Personal mi se par foarte ușor de folosit și ușor de înțeles.
Nu e mare filozofie, sunt niște constante organizate într-un anumit fel care practic nu te lasă să greşeşti asignarea variabilei de acest tip. Dacă se foloseşte la asignare orice alta valoare din afara intervalului compilatorul va returna o eroare. Dacă se foloseşte la asignare o valoare numerica care este totuși egala cu un termen din enumerare atunci şi în acest caz va returna o eroare. Referinte:
C Enumeration Declarations
C_and_syntactically_similar_languages

Template-uri in Php

Acum vreo doi ani am găsit clasa de mai jos pentru lucrul cu template-uri. Cred ca e cea mai simpla clasa de acest gen. Practic se parsează un fișier html unde se înlocuiesc tagurile {nume} cu un conținut setat de către utilizator. Daca nume = „

Continut

” atunci peste tot unde se gaseste {nume} se va inlocui cu codul html. Continut „tpl.class.php”:

 

/***************************************************************************
*
* Author : Eric Sizemore ( www.secondversion.com & www.phpsociety.com)
* Package : Simple Template Engine
* Version : 1.0.2
* Copyright: (C) 2006 - 2007 Eric Sizemore
* Site : www.secondversion.com
* Email : hide@address.com
* File : tpl.class.php
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
***************************************************************************/

// Template engine
class template
{
/**
* Template variables and their replacements
*
* @var array
*/
var $tpl_vars;

/**
* Constructor
*/
function template()
{
$this->tpl_vars = array();
}

/**
* Assign our variables and replacements
*
* @param array Template variables and replacements
* @return none
*/
function assign($var_array)
{
// Must be an array...
if (!is_array($var_array))
{
die('template::assign() - $var_array must be an array.');
}
$this->tpl_vars = array_merge($this->tpl_vars, $var_array);
}

/**
* Parse the template file
*
* @param string Template file
* @return string Parsed template data
*/
function parse($tpl_file)
{
// Make sure it's a valid file, and it exists
if (!is_file($tpl_file))
{
die('template::parse() - "' . $tpl_file . '" does not exist or is not a file.');
}
$tpl_content = file_get_contents($tpl_file);

foreach ($this->tpl_vars AS $var => $content)
{
$tpl_content = str_replace('{' . $var . '}', $content, $tpl_content);
}
return $tpl_content;
}

/**
* Output the template
*
* @param string Template file
*/
function display($tpl_file)
{
echo $this->parse($tpl_file);
}
}

Un exemplu foarte simplu folosind clasa „template” arata cam asa:

 
include("tpl.class.php");

$header = "Header";
$meniu = "linkuri meniu";
$continut = "continut pagina";
$footer = "linkuri footer";

$tpl_pagina = &new template();
$tpl_pagina->assign(array('modul_header' => $header,
'modul_meniu' => $meniu,
'modul_continut' => $continut,
'modul_footer' => $footer
)
);

$pagina_de_afisat = $tpl_pagina->display_template('templates/new-newsletter/interfata.tpl');
echo $pagina_de_afisat;

Conținutul interfata.tpl este o pagina normala html dar care conține următoarele variabile {modul_header} {modul_meniu} {modul_continut} {modul_footer}, care vor poziționate în website unde dorește utilizatorul. Practic posibilitățile sunt nelimitate, iar partea de html este complet deconectata de Php. Mai simplu de atat nu se poate.
O zi plăcută tuturor !

Trimiterea de emailuri folosind PHP si PhpMailer

Pentru a trimite emailuri programatic prin Php se poate folosi clasa PhpMailer. E foarte ușor de folosit și de încredere. Mai exista si alte clase specializare pentru trimiterea de emailuri dar personal o prefer pe aceasta pentru ca se configurează foarte simplu.
Un exemplu simplu folosind SMTP:

 
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "yourname@yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK

n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}

O zi buna tuturor !

Proiecte de automatizari

An Experiment In Home Automation Creative Use of Home Automation Resources and the Creation of an Interactive Video Stimulates Sales of New Condo

Office / Home Automation