Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Thursday, August 30, 2018

Laravel, Swiftmailer and Uncaught Swift_TransportException

Writing PHP applications that deliver email notification helps to build a versatile system that uses the most basic communication media on the Internet. The Email.

Getting the Email out would require knowledge of the Email server in use to deliver 1 or thousands of email notifications. Common Email use SMTP, sendmail, postfix or a custom Transport implementation for corporate use. There are security and reliability concerns when passing to any Email server. Some of which include protection from email header injection attacks, MIME compliant, HTML/multipart emails, inline or embedded images.

Swift Mailer helps to handle most of these things. Why reinvent the wheel? In order to use it, the application should support PHP 7.0 or higher. Installation through Composer simplifies the whole process.

$ composer require "swiftmailer/swiftmailer:^6.0"

More details are found at Swift Mailer.

Purpose

Back to the original reason of this post. On a recent Laravel application, tested was carried out and checklist done on Centos Linux development server However when deployed to production Centos Linux server, email notification produced following error;

PHP Fatal error: Uncaught Swift_TransportException: Connection could not be established with host EMAILSERVER_NAME[Permission denied #13]

The full error is shown below.

[Thu Aug 30 14:35:54.225637 2018] [php7:error] [pid 18234] [client IPADDRESS:32852] PHP Fatal error: Uncaught Swift_TransportException: Connection could not be established with host EMAILSERVER_NAME[Permission denied #13] in /var/www/tboxmy/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:277\nStack trace:\n#0 /var/www/tboxmy/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(62): Swift_Transport_StreamBuffer->_establishSocketConnection()\n#1 /var/www/tboxmy/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(113): Swift_Transport_StreamBuffer->initialize(Array)\n#2 /var/www/tboxmy/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()\n#3 /var/www/tboxmy/public/info/testemail.php(21): Swift_Mailer->send(Object(Swift_Message))\n#4 {main}\n thrown in /var/www/tboxmy/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 277 

 Solution

I am sure there are other possible ways to get this error, but in my case it was SELINUX. On the development selinux was on permissive and on production it was enforcing (quite strictly).

The next time this happens; here are the steps to take.

Determine selinux status and the booleans.

$ sestatus
. . .
$ getsebool httpd_can_sendmail
httpd_can_sendmail --> off
$ getsebool httpd_can_network_connect
httpd_can_network_connect --> off

Turn the permission to ON.

$ sudo setsebool -P httpd_can_sendmail 1
$ sudo setsebool -P httpd_can_network_connect 1

Restart the web server.
Done.

Wednesday, January 10, 2018

Apache not sending emails on Centos 7

Applications on Apache webserver that are working fine but can't send out emails is a real headache. Especially if everything was working on the development server. Example of error encountered;

Could not execute: /usr/sbin/sendmail

In Wordpress, it refuses to send email. Once such instance is the Forget password window and you see the message
The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function.

This is ONE possibly most common situation. 

On most Development servers, the SELinux is probable turned OFF or in permissive mode. However on the Production servers, they are almost always set to ON. In the web server document directory, check if the following SELinux status;

$ getsebool httpd_can_sendmail

It should be in status OFF. Change the status to ON and restart Apache with the command

$ setsebool -P httpd_can_sendmail on
$ systemctl restart  httpd.service

Second common situation

Still not receiving emails from apache or Wordpress? It is possible Postfix SMTP server is using values that the email relay SMTP is not accepting. Check the maillog for any errors such as this;

said: 450 4.1.8 <apache@production.localdomain>: Sender address rejected: Domain not found (in reply to RCPT TO command))  

Or

sendmail[2450]: NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied

This is a story for another time.

Monday, June 20, 2016

Backup Thunderbird 45 on MS Windows 10

Just after installing the Kubuntu Jaunty 9.04 Linux, its time to restore some of my stuff. Firstly, I need communications and this is via my Thunderbird.

Thunderbird email client allow access of emails from online email providers and a local storage of email. It may be necessary to move these local emails and local Thunderbird profile to another PC or to be saved as a backup.



Here is the manual method. Save the local configurations by copying the files as listed in these locations to the backup location.

  • Thunderbird 45.1.1
  • MS Windows 10

Backup

Step 1. Identify location of the files for backup.

There are a few ways to do this, one of which is to open Thunderbird menu (3 horizontal lines), click Options-> Account settings. Then follow the steps below.
1. Signature. Right click the email account-> Account settings. In the right window, look for
Attach signature from a file instead



2. Email configuration profile. Right click the email account-> Account setting ->Server Settings ->Local directory





3. Local folders for offline access. Right click the Local folders ->Server Settings ->Local directory



4. Digital certificates. Right click the email account-> Account setting ->Manage Identities...
Then choose the email profile(s) and click Edit and choose the tab for Security.


Step 2. Stop Thunderbird and compact all large folders.

Example,
Inbox
Sent

Empty all Deleted folders

Step 3. Copy files in Step 1 to the new location.


Restore:

Step 1:
Copy the directory profile back to the new system

Step 2:
In the terminal create an email profile that uses the old directory, type

thunderbird -profilemanager

(WIP)

Thursday, November 13, 2014

Howto set Default Account in Thunderbird

Mozilla Thunderbird is a widely used Email client that is fast, friendly and can be extended with many plug-ins available for Linux, OS X and MS Windows platform. Licensed with Mozilla Public License 2.0 it is an open source software (OSS) with an active list of developers. The current version being 31 and more information can be found at Mozilla website.
Mozilla Thunderbird


Many email accounts can be created within this email client and this makes it easy to see all emails from one screen. Emails can be composed by opening the Thunderbird email client or via links that user clicks to activate the email composer. In order improve efficiency, one of the accounts can be assigned as the default email account and this is normally indicated in bold. This allows all new emails to use this account and users do not need to choose the account. I have listed the steps tested for Thunderbird version 24 and 31 where the example shows account2 in bold as the default account and we want to switch the default to account1.

Step 1: Open Thunderbird account's setting.

Start Thunderbird and from its menu bar at the top (default), choose Tools ->Account Settings...
Identify the default account that is used to send out emails. This is in bold, for example "account2"

Step 2: Set the default account

Choose the account to be used as the default. In this case, its "account1". At bottom of the window, click Account Actions. Choose "Set as Default".

Click OK, notice that this email account will go to the top of the list and is in bold font. Ensure all email screens are closed and restart Thunderbird.

Tuesday, August 20, 2013

User Identities in Thunderbird

Thunderbird have see lots of changes but the basic features for email have been retained. One of this, is being able to choose different ways to compose a message before it is sent out.

Example case 1; I have different signatures for friends, customers, special clients and for the general use. Switching signatures is so easy.

Example case 2; Some sent emails must be save to my SPECIAL folder.

Example case 3: Some emails must contain a CC or BCC to specific persons.

Example case 4: When I replay some quote of previous email is at the top and some at the bottom.

We can get this done is a few simple steps (I list the general steps here);

Step 1: In TB, click Tools ->Account settings...
Select the Email account and set the default email settings for

Your name:
Email Address:
Reply-to Address:
Organization:
Signature Text:

Step 2: Strongly suggest to create a text file and place the signature and name. 
Use the option for
Attach the signature from a file instead (text, HTML, or image)

Step 3: Configure following settings;
Copies and folders
Composition & Addressing
Security

Step 4: Click the Email account (selected in step 1)
Click button Manage Identities...
Click Add...

Enter the alternative email configuration. E.g. The alternative email signature.

Click OK, Close. You can continue to create as many identities as you like.
Click OK

DONE!
Try to send an email, click Write button.

Notice the "From" have a drop down list of all the different styles and configuration that you have created.

Friday, May 22, 2009

Backup Thunderbird2

Just after installing the Kubuntu Jaunty 9.04 Linux, its time to restore some of my stuff. Firstly, I need communications and this is via my Thunderbird.

Backup:
I found it necessary to disable some of the extensions to allow the new Thunderbird to run properly.
Copy the Thunderbird directory profile (usually it goes with some crazy name followed by your profile name to the backup device. Example

cp ~/.mozilla-thunderbird/izwvasdx.default /media/backupdisk

Restore:
Step 1:
Copy the directory profile back to the new system

Step 2:
In the terminal create an email profile that uses the old directory, type

thunderbird -profilemanager


Ref: Mozilla

Sunday, May 3, 2009

[Jaunty]Installing Thunderbird 2 on Kubuntu Linux 9.04

Just after installing Kubuntu Linux 9.04 and all seems well, the email client is the next stop.

Install Thunderbird 2.0 from a terminal

$ sudo apt-get install thunderbird thunderbird-dispmua mozilla-thunderbird-bidiui lightning-extension enigmail

The installation included the following packages:
calendar-google-provider calendar-timezones

Tuesday, October 28, 2008

Rise of Email spam

The Sophos Report on spam in Aug 08 will really make many companies re-look at their anti spam capability, in particular MS Windows based systems.
There are a few employees who attempt to inform or complain in the increase number of spam to the ICT managers, but these are ignored or placed in a low level of importance. Worst, I heard that one MS Exchange based organisation decided that nothing much can be done and employees were to delete spams on their own.

Some of the spams are Agent-HNY Trojan Horse, is disguised as the Penguin Panic arcade game for Apple iPhones, EncPk-CZ Trojan which pretended to be a Microsoft security patch, and the Invo-Zip malware, which masqueraded as a notice of a failed parcel delivery from firms such as UPS.

Spam origins are ranked highest from US, Russia, Turkey and China. If more desktops for critical areas are migrated to Linux, then these desktops can be proctected.

Tuesday, September 30, 2008

Spam, Scam and Hoaxes

Internet, Email and other forms of Online tools are increasingly getting accessible to all level of users. This includes the students, teachers, housespouse (i thought housewifes may soon be subjective), business person, security guards, cleaners and other professions.

There are some out to take advantage of the new comers, ignorant or busy Internet people with these new technologies. The ideas may be as old as the Ford T but many people still find themselves a victim. As a start, if any thing on the Internet is doubtful or sound too opportunistic there are some web sites that list common issues.

  1. Hoax-Slayer (http://www.hoax-slayer.com )
  2. Scambusters (http://www.scambusters.org )
  3. Sophos (http://www.sophos.com)
There are many more sites, but the list above is a start.

Friday, May 23, 2008

Thunderbird on CentOS 5.1

Everyone is using Thunderbird on MS Windows, Ubuntu Linux and Fedora Core Linux. So, why shouldnt Centos 5.1 be able to install?

1. Download Thunderbird 2 from Mozilla (http://www.mozilla.com/en-US/thunderbird/) or other mirros like (http://mirror.oscc.org.my/mozilla/thunderbird/). I downloaded thunderbird-2.0.0.14.tar.gz to the directory /tmp.

2. Extract the files

3. Open a terminal and login as root to thee directory /opt
su -
cd /opt

4. Copy the extracted forlders to /opt
cp -rf /tmp/thunderbird /opt

5. Install the older library of libstdc++.so.5 (5.1 comes with version libstdc++.so.6)
yum install compat-libstdc++-33.i386

6. Test the Thunderbird as a normal user
/opt/thunderbird/thunderbird

7. Copy the icons to the user wide pixmap
cp thunderbird/icons/mozicon*.xpm /usr/share/pixmaps/

8. When Thunderbird starts, it complains about the mode for /var/spool/mail, as it cannot write to this folder. As root do the following
chmod 01777 /var/spool/mail

Add the application launcher in the panel/menu using the mozicon icon. Only things left is to install other plugins. My first plugins are always the Calendar (lightning) and birthday.

-

Monday, May 12, 2008

Thunderbird Troubleshooting

IMAP maximum cached connection error
The Thunderbird 2.0.0.14 email client on Ubuntu 7.10 took some getting use to. Today something had to happen. The IMAP server returned an error on my Thunderbird (email client) with the following Alert popup.


Something must have changed at the mail server over the weekend. Using the Web client, things were all fine, so this may be a Thunderbird and IMAP setting problem. At the client side, do the following to clear it. Originally I had the value 5 for the number of cached connections.

Step 1: Open Thunderbird. Choose Edit ->Account Settings
Step 2: Identify which account having the IMAP Alert problem and choose Server Settings and click on Advanced.
Step 3: In Maximum number of connections to cache from 5 to four. If this value does not work, keep reducing by one.
Step 4: Click OK. A second time OK to accept the changes.
Step 5: Restart Thunderbird to ensure things are reset. However, it still did work without restarting.

The "This body part will be downloaded on demand." message.
When the body of an email says "This body part will be downloaded on demand." and the attachments seem corrupted you cant access the Email.

Possibility 1: You are in offline mode and the downloads have been restricted.
Ensure the View -> Display Attachments Inline is checked.

Possibility 2: The message headers go messed up.
Rebuild the specific folder index table. Rebuilding the .msf file for that folder. Right click on the folder, select properties, general information and then press the "Rebuild Index" button. If that doesn't recover all of the messages its probably due to your folder being corrupted.

See Mozillazine
--

Friday, April 25, 2008

Using Apache to forward request

I am getting complaints from users that the mail server is not accessible from outside the local network due to the port number being block at other networks. My mail server is using port 8383 for webmail. Following steps allow my webmail to be accessed without needing to change the mail server settings.

The Plan
I need to setup an apache 2 on Linux and later reroute the DNS to use this new sever. All this using mod proxy in Apache.

What is mod proxy? see Apache site
"A typical usage of a forward proxy is to provide Internet access to internal clients that are otherwise restricted by a firewall. "

In this example my mail server details:
servername: mail.myserver.com.my
serverip: 192.93.20.3

STEP 1: Setting up the mod proxy on 192.93.20.4
My proxy is on CentOS 5.1 with Apache 2 (httpd-2.2.3-11.el5_1.centos.3)
  1. Install a Linux with Apache 2 and open the httpd.conf file

    vi /etc/httpd/conf/httpd.conf

  2. Make sure you have the following LoadModule lines (it waas there)
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so

Go to section three of the file and add

ServerName mail2.myserver.com.my
ProxyPass / http://firewall.myserver.com.my/
ProxyPassReverse / http://firewall.myserver.com.my/
RewriteEngine On
RewriteRule ^/$ http://mail.myserver.com.my:8383/ [P]



STEP 2: Redirect DNS
  1. Configure the DNS to accept mail2.myserver.com at the new server 192.93.20.4 which defaults to port 80
-

Thursday, April 17, 2008

Evolution vs Thunderbird vs Outlook

Intrduction to emails

Mail User Agent (MUA) is also known as an Email client. MUA is used to request email
from a Mail Transfer Agent (MTA). The request can be made in 2 forms:


  1. Post Office Protocol (POP3): Messages on the server cannot be flagged (as seen or
    forwarded) and messages are removed by default from the server to the MUA.

  2. Internet Message Access Protocol (IMAP): Messages on the server can be flagged and
    directories are used to managed emails on the server.


MUA must meet formating of email header ( To, CC, BCC, Reply-To) and footer as
described in RFC2822.


For firewall settings, MUA access a standard MTA via port 25 (SMTP). Currently
Transport Layer Security (TLS) is being used in many MTA for connection and transfer
security. Other ports of importance (plain/encrypted):
POP3 (110/995)

IMAP4 (143/993)

HTTP (80/443)

Anyone can read the contents or body of an email moving across MTA and MUA. Therefore
encryption of the Email content is used to protect the sensitive data. This can be in
two forms:S/MIME: requires a trusted body to recognise the userOpenPGP: users can recognise each other (no third party needed)


(T) PluginsLightning: Calendar tool support for WebDav and iCalendarEnigmail: adds OpenPGP message encryption and authentication to your email client. It features automatic encryption, decryption and integrated key management functionality. Enigmail requires GnuPG (www.gnupg.org) or Gpg4win for the cryptographic functions. Note: GnuPG and Gpg4win is not part of the installation.


(O) Viruses


(E) Support ServersMS Exchange, POP3, IMAP, Lotus

(E) clientGmail, Yahoo, AOL, Hotmail


(E) License: LGPL

(T) License: MPL, MPL/GNU GPL/GNU LGPL

(O) License: part of MS Office


(T) Calendar: iCalendar, WebDav

(O) Calendar: iCalendar, WebDav

(E) Calendar: iCalendar, WebDav


Platforms

Linux (E),(T)

MS Windows (T),(O)


Links:




Wednesday, April 16, 2008

Email Signatures and address book in Thunderbird 2

After having some issues with Evolution 2.12.1 on Gnome, I decided to have Thunderbird replace the Evolution Email client. After installing Thunderbird 2.0.0.12 from the mozilla.com website I needed to transfer the Addressbook from Evolution and add my Email signature. So here are the steps I took.

What is Thunderbird?
  • Handles junk mail using Bayesian filtering and detects scams
  • Handle Emails with views, tags, filters, search and virtual folders help
  • Provide reader for RSS feeds like streams of email with filters, search and labeling
A. Importing Addressbook from Evolution
No, there is no direct import for Thunderbird. Thunderbird support import of addressbook in the form of LDIF, csv and tabs. Evolution could only export addresses with the tool evolution-addressbook-export but this continued to give unexplainable errors that seem rather familiar in previous versions. For the record, here is how the command is used

evolution-addressbook-export --format=csv > ~/Desktop/contacts.evolution.csv
  1. So, what I did in the end was to export the Evolution address with the menu
    File ->Save Address Book as VCard
    Select the Desktop and saved as contactlist.vcf
  2. Use a converter to convert VCard to LDIF. For this example I accessed the site http://labs.brotherli.ch/vcfconvert and uploaded the VCard file. No big deal as there was nothing sensitive. However there were some converters that could be installed on the PC for more peace of mind about sensitivity of the data. I saved the file back as contactlist.ldif

    The idea is to convert VCF to LDIF

  3. In Thunderbird, open the addressbook and choose the menu
    Tools ->Import
    Select the contaclist.ldif file
B. Adding a signature for outgoing Emails.
You can add a VCard or a text/HTML file as a signature.
  1. Adding text signature. Create a textfile with your signature and store it on your harddrive. For example save as signature.nicholas.txt
  2. In Thunderbird choose
    Edit ->Account Settings
  3. Choose a profile and checked
    Attach this signature
  4. Click the Choose button and select the signature file signature.nicholas.txt
  5. Click OK

Blog Archive