I'm working on a little e-cards project.
I have to send emails from my remote server with PHPMailer.
localy I'm using this configuration (with my own Gmail email adress) and it works perfectly.
/ssi/mail.config.php
<?php
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = '587';
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'private#gmail.com';
$mail->Password = '***secret***';
$mail->SMTPSecure = 'tls';
?>
On my remote server (hosted on one.com) I have created an email account for the domain.
I changed the host and the port like the helpdesk said ... but I don't get it to work remotly.
<?php
'ssi/mail.config.php'
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8';
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'send.one.com';
$mail->Port = '25';
$mail->SMTPSecure = 'none';
$mail->SMTPAuth = true;
$mail->Username = 'ecards#iveweygers.be';
$mail->Password = '***secret***';
$mail->SMTPSecure = 'none';
?>
Thanks again!
Looking at the one.com page, there are a few things wrong with this. For smtp they say to use Port 465 with SSL encryption. So, your code should be:
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8'; // You can remove this line, utf-8 is the default.
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'send.one.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'ecards#iveweygers.be';
$mail->Password = '***secret***';
Also worth noting -- and something that it took me a LONG time to find: My SMTP server required authentication to send an email. I assumed that the SMTPAuth = true; took care of that but it did not. I noticed that one.com does as well -- i.e. they tell you to click the button in Outlook that says that your outgoing server requires authentication.
I finally got it to work by putting this at the top of my file:
$pop = new POP3();
$pop->Authorise("send.one.com", 465, 30, "ecards#iveweygers.be", "***secret_password***", 1);
That takes care of the authentication. Then you can jump into the $mail = new PHPMailer(true) and setting all of your parameters and sending the mail.
So your entire file should look like this:
$pop = new POP3();
$pop->Authorise("send.one.com", 465, 30, "ecards#iveweygers.be", "***secret_password***", 1);
$mail = new PHPMailer(true);
$mail->CharSet = 'utf-8'; // You can remove this line, utf-8 is the default.
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'send.one.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'ecards#iveweygers.be';
$mail->Password = '***secret***';
You have not said how it's failing, which makes diagnosis difficult.
I really wouldn't recommend any service that uses authentication without encryption. There is no meaning to setting SMTPSecure to 'none' - just set it to an empty string (or don't set it at all) if you don't want SSL or TLS, and you only need to do that once (not twice as in your code).
The other solutions did not work for me; this one did:
$mail->isSMTP();
$mail->Host = 'mailout.one.com';
$mail->SMTPAuth = false; // disable SMTP authentication
$mail->Username = '[your one.com-email]';
$mail->Password = '[your one.com-email password]';
$mail->SMTPSecure = ''; // leave this blank!
$mail->Port = 25;
Let me know if it helped you, too!
Related
My script is working so far to open a remote FTP connection, change directory, and download a file. My last two steps would be to delete the remove file once it's fully downloaded and then close the connection. ACF documentation (and cfdocs) seems to have very little information on this. Here's what I have so far:
ftpConnection = ftpService.open(
action = 'open',
connection = variables.ftpConnectionName,
server = variables.ftpServerName,
username = '***************',
password = '***************',
secure='true');
if( ftpConnection.getPrefix().succeeded ){
fileList = ftpService.listdir(directory = variables.ftpPath, connection= variables.ftpConnectionName, name='pendingFiles', stopOnError='true').getResult();
if( fileList.recordCount ){
changeFtpConnectionDir = ftpService.changeDir(
connection = variables.ftpConnectionName,
directory = variables.ftpPath);
getFtpConnection = ftpService.getFile(
connection = variables.ftpConnectionName,
remoteFile = fileList.name,
localFile = local.localPath & fileList.name,
failIfExists = false,
timeout = 3000
);
deleteRemoteFile = ftpService.remove(
connection = variables.ftpConnectionName,
remoteFile = fileList.name
};
closeFtp = ftpService.close(
connection = variables.ftpConnectionName
);
};
};
Error is thrown on the remoteFile = fileList.name. Since I already changed directory I don't think I need to put the full path here.
I put the entire script up since there doesn't seem to be many resources out there about using the newer ftpServer() functions.
D'oh - my issue was a typo:
deleteRemoteFile = ftpService.remove(
connection = variables.ftpConnectionName,
remoteFile = fileList.name
);// had } instead of )
I'll still leave this up as a resource for ftpService()
On my last server i could send smtp automatic emails on port 25 but after migrating the server on virtualmin install, i can't make it work
Here's the old working postfix config
myhostname = ##REVERSE_DNS_IPV4##
myorigin = ##REVERSE_DNS_IPV4##
mydestination = localhost.localdomain, localhost, ##REVERSE_DNS_IPV4##
relayhost =
mynetworks = 127.0.0.0/8, ##IPV4_PUBLIQUE_SERVEUR##
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual_aliases.cf,mysql:/etc/postfix/mysql-virtual_aliases_comptes.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual_domaines.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual_comptes.cf
virtual_mailbox_base = /var/spool/vmail/
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql-virtual_quotas.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = "La boite mail de votre destinataire est pleine, merci de reessayez plus tard."
virtual_overquota_bounce = yes
# adresses d'expedition
smtpd_sender_restrictions =
permit_mynetworks,
warn_if_reject reject_unverified_sender
# adresses de destination
smtpd_recipient_restrictions =
permit_mynetworks,
reject_unauth_destination,
reject_non_fqdn_recipient
# client
smtpd_client_restrictions =
permit_mynetworks
Here is the current not working configuration
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
append_dot_mydomain = no
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
myhostname = vsweb03.help-amor.be
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = 7dd18f2b56a5, vsweb03.help-amor.be, localhost.help-amor.be, loc$
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reje$
allow_percent_hack = no
sender_dependent_default_transport_maps = hash:/etc/postfix/dependent
inet_protocols = ipv4
I must that the old configuration allowed php mail function, impa/pop/smtp emails and django with no user smtp automatic emails
The new one allow everything except django with no user on port 25 automatic smtp emails.
DOes somebody know which directive i need to modify?
Un big thank you to any help
Ok i found the problem,
I just add this and it works with smtp non auth user on port 25
smtpd_sender_restrictions =
permit_mynetworks,
warn_if_reject
IdConnectionInterceptOpenSSL->SSLOptions->Method = sslvSSLv23;
IdConnectionInterceptOpenSSL->SSLOptions->Mode = sslmClient;
IdConnectionInterceptOpenSSL->SSLOptions->VerifyDepth = 0;
//....
TCHAR* SIR = SIRX[ix].c_str();
AnsiString rtf;
TStringStream * Send = new TStringStream(rtf) ;
Send->Write(SIR, (SIRX[ix]).Length()); // <-- new
Send->Position = 0;
TMemoryStream *Receive = new TMemoryStream() ;
AnsiString ADRESA = "https://webservicesp.anaf.ro:443/PlatitorTvaRest/api/v1/ws/tva";
IdHTTP->Request->Accept = "application/json";
IdHTTP->Request->ContentType = "application/json";
IdHTTP->Request->Connection = "Keep-Alive";
IdHTTP->Post(ADRESA, Send, Receive);
If I use a direct Internet connection, it works fine.
My problem appear when I use a proxy server for Internet connection.
I put
IdHTTP->Request->ProxyServer = PROXY_SERVER;
IdHTTP->Request->ProxyPort = StrToInt(PROXY_PORT);
if(PROXY_USER.IsEmpty() == false)
IdHTTP->Request->ProxyUsername = PROXY_USER;
if(PROXY_PASSW.IsEmpty() == false)
IdHTTP->Request->ProxyPassword = PROXY_PASSW;
But the error appears like this : connection closed gracefully to the first interrogation, and after, the same interrogation give 501 Not Implemented.
Where is the problem? Are there any solutions?
I'm trying to write an application that would work with the EWS proxy classes. To generate proxy classes I used gsoap (compiled OpenSSL).
I have implemented a library that works with EWS, but. Net.
The problem is this: I have no idea how to implement a connection to the server.
Doing the following:
ExchangeServiceBindingProxy *proxy = new ExchangeServiceBindingProxy("https://192.168.0.49/EWS/exchange.asmx");
soap *pSoap = proxy->soap;
pSoap->userid = "user1";
pSoap->passwd = "password1";
pSoap->recv_timeout = 300;
pSoap->send_timeout = 300;
SOAP_ENV__Header *header = new SOAP_ENV__Header();
header->ns3__RequestServerVersion = new _ns3__RequestServerVersion();
header->ns3__RequestServerVersion->soap = pSoap;
header->ns3__RequestServerVersion->Version = ns3__ExchangeVersionType__Exchange2010;
pSoap->header = header;
//get root folder ID
ns3__DistinguishedFolderIdType *dfit = new ns3__DistinguishedFolderIdType();
dfit->Id = ns3__DistinguishedFolderIdNameType__inbox;
//set the props that we want to retrieve
ns3__FolderResponseShapeType *frst = new ns3__FolderResponseShapeType();
frst->BaseShape = ns3__DefaultShapeNamesType__AllProperties;
//get folder
ns1__GetFolderType *gftRoot = new ns1__GetFolderType();
gftRoot->FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit;
gftRoot->FolderShape = frst;
__ns1__GetFolderResponse response;
int error = proxy->GetFolder(gftRoot, response);
As a result, getting the error: SLL_ERROR.
I know, that i`m doing something wrong. But what? What i should to do, to use proxy classes functions?
I resolved it by myself:
Added to project LibNTLM and added to preprocessor WITH_NTLM.
Also changed code, a little bit:
ExchangeServiceBindingProxy *proxy = new ExchangeServiceBindingProxy(endpoint.c_str());
soap *pSoap = proxy->soap;
pSoap->userid = "Ivan1";
pSoap->passwd = "1";
pSoap->ntlm_challenge = "";
pSoap->authrealm = "Ursa-Minor";
pSoap->ssl_flags = SOAP_SSL_NO_AUTHENTICATION;
//pSoap->keep_alive = true;
pSoap->mode = SOAP_IO_KEEPALIVE;
//get root folder ID
ns3__DistinguishedFolderIdType *dfit = new ns3__DistinguishedFolderIdType();
dfit->Id = ns3__DistinguishedFolderIdNameType__inbox;
//set the props that we want to retrieve
ns3__FolderResponseShapeType *frst = new ns3__FolderResponseShapeType();
frst->BaseShape = ns3__DefaultShapeNamesType__AllProperties;
//get folder
ns1__GetFolderType *gftRoot = new ns1__GetFolderType();
gftRoot->FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__size_NonEmptyArrayOfBaseFolderIdsType = 1;
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit;
gftRoot->FolderIds = (ns3__NonEmptyArrayOfBaseFolderIdsType*)dfit;
gftRoot->FolderShape = frst;
__ns1__GetFolderResponse response;
int qq = proxy->GetFolder(gftRoot, response);
return true;
But now i have enother problems: Error 500: Internal Server Error
I'm stuck on a common problem but I don't really know how to get out.
The browsers don't keep the auth session.
Here is my setup.
"application.ini"
resources.session.save_path = ROOT_DIR "/public/session"
resources.session.gc_maxlifetime = 864000
resources.session.remember_me_seconds = 864000
".htaccess"
php_value session.gc_maxlifetime 864000
php_value session.save_path /Users/user/mydomain.com/public/session/
"bootstrap.php" (_initSessionNamespaces it's the first method I call)
protected function _initSessionNamespaces()
{
$this->bootstrap('session');
Zend_Session::start();
}
"SigninController.php"
// set adapter
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('user')
->setIdentityColumn('email')
->setCredentialColumn('password')
->setCredentialTreatment($salt)
->setIdentity($values['email'])
->setCredential($values['password']);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$user = $authAdapter->getResultRowObject();
$auth->getStorage()->write($user);
// init session cookie
$session_auth = new Zend_Session_Namespace('identity');
$session_auth->setExpirationSeconds(864000);
return true;
}
the session file that has been created in the directory is this:
language|a:1:{s:6:"locale";s:2:"en";}identity|a:2:{s:14:"filterDistance";i:5;s:5:"email";s:15:"test#test.com";}Zend_Auth|a:1:{s:7:"storage";O:8:"stdClass":20:{s:2:"id";s:20:"8c3b329b0f3d71f4566c";s:12:"date_created";s:19:"2012-12-19 20:30:29";s:12:"date_updated";s:19:"2013-01-12 00:02:19";s:14:"date_lastlogin";s:19:"2013-01-16 15:30:01";s:7:"site_id";s:4:"this";s:14:"site_lastlogin";s:4:"this";s:6:"active";s:1:"1";s:4:"role";s:5:"admin";s:8:"username";s:5:"test";s:8:"password";s:40:"63fb7f1941083ca0284481d8ad557e2b0c5bf5f4";s:4:"salt";s:40:"70be1adbff1c0bd6f82sc1fcaf6d2fef3c869b6c";s:10:"first_name";s:5:"pippo";s:9:"last_name";s:0:"";s:5:"email";s:15:"test#test.com";}}__ZF|a:1:{s:9:"Zend_Auth";a:1:{s:3:"ENT";i:865358347332;}}
And usually in a Controller I call the user info in this way
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->info = $auth->getIdentity();
}
When I restart the browser it create a new empty session file like this:
language|a:1:{s:6:"locale";s:2:"it";}
I'm stuck here for 2 days... what can I do??
I solved it adding this in application.ini
resources.session.cookie_lifetime = 864000
I think this could help someone :)