Configuring swift mailer [dummie]

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
User avatar
markis1986
Forum Newbie
Posts: 9
Joined: Fri Oct 19, 2007 12:58 am

Configuring swift mailer [dummie]

Post by markis1986 »

Hi,
First of all, i'd like to say, that i'm a newone in php. So if the question is quite stupid, please don't laugh.
So, here i go :

I'm working under windows XP, i have installed XAMPP v.1.6.4.
I'd like to create a simple form which could send an email. (for example, there would be only a text field to write a message, and a button to send the written message. Recepients adress, and a subject, would be in a php "memory".
I've read little bit about swift mailer, and i got to the conclusion - that it should fit my poor need.

I tried to CONFIGURE it by myself, but only got errors :(

Correct me if i'm wrong : if you use swift mailer, there's no need to use php mail() function?

My form would use my e-mail, created in gmail.

I get this error, most of times:

Code: Select all

Expected response code(s) [334] but got response [530 5.7.0 Must issue a [b]STARTTLS [/b]command first y18sm7455427fkd]
I would be ver grateful, if you helped me to configure my swift mailer.
By the way, i have installed the smtp server (QK SMTP server) if it's needed.

GMAIL settings:
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587
Account Name: your Gmail username (including @gmail.com)
Email Address: your full Gmail email address (username@gmail.com)
Password: your Gmail password
Do i need to edit my php.ini file?
chuckl
Forum Commoner
Posts: 61
Joined: Wed May 23, 2007 7:36 am

Post by chuckl »

I would guess that you are trying to connect to Gmail on port 587. You should ne using port 465.
User avatar
markis1986
Forum Newbie
Posts: 9
Joined: Fri Oct 19, 2007 12:58 am

Post by markis1986 »

OK, i managed to make "runTestOfBasicSend.php" to send a message (it wrote : Message sent successfully)

The problems wew :

1) You were right, i was using bad port
2) I did not change line " const SMTP_ENCRYPTION = "ssl";" in testconfiguration.php file
3) i didnt enable openssl extension in php.ini file.

OK.

Somehow i managed to pass the test ... And get the test e-mails.
So, now i would like to know, how does this swift class (i hope this is what php'er calls class) is used?
I need to send simple text from

Code: Select all

<textarea> </textarea>
which is in a form.
What is the syntax of sending mail? What is further configuration ...
:( man i'm green
Last edited by markis1986 on Sat Nov 03, 2007 12:11 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Run the following in a new file and tell us the results please.

Code: Select all

<?php

$neg = array('off', 0, false, '', null);
$flags = array(
	'Register Globals' => 'register_globals',
	'Short Tags' => 'short_open_tag',
	'Display Errors' => 'display_errors',
	'Magic Quotes GPC' => 'magic_quotes_gpc',
	'Magic Quotes Runtime' => 'magic_quotes_runtime',
	'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
	$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
	$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";

$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
	$le .= '   ' . implode('   ', array_slice($gle, $i, $wide)) . $eol;
}

$ec = array(
	'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
	'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
	'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
	'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
	if (($t & $v) == $v)
	{
		$e[] = $n;
		$t ^= $v;
	}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
	$e2 = array();
	foreach ($ec as $n => $v)
	{
		if (!in_array($n, $e) and $n != 'E_ALL')
		{
			$e2[] = $n;
		}
	}
	$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
	$er = $er . ' (' . implode(' | ', $e) . ')';
}

if (!$cli)
{
	echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}

echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
	echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;

if (!$cli)
{
	echo '</pre></body></html>', $eol;
}

?>
User avatar
markis1986
Forum Newbie
Posts: 9
Joined: Fri Oct 19, 2007 12:58 am

Post by markis1986 »

The results were

Code: Select all

PHP Version: 5.2.4
PHP OS: WINNT
Error Reporting: 6135 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: On
Short Tags: On
Display Errors: On
Magic Quotes GPC: On
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: C:\Programos\Web\xampp\apache\bin\php.ini
Loaded Extensions:
   bcmath           calendar         com_dotnet       ctype         
   session          filter           ftp              hash          
   iconv            json             odbc             pcre          
   Reflection       date             libxml           standard      
   tokenizer        zlib             SimpleXML        dom           
   SPL              wddx             xml              xmlreader     
   xmlwriter        apache2handler   gd               gettext       
   imap             mbstring         exif             mime_magic    
   ming             mssql            mysql            mysqli        
   openssl          pdf              PDO              pdo_mssql     
   pdo_mysql        pgsql            pop3             smtp          
   soap             sockets          SQLite           xmlrpc        
   xsl              zip              Zend Optimizer
Post Reply