Menu
Reply
  • 403
  • 3
  • 39
aaronsloman
Fibre optic
362 Views
Message 1 of 11
Flag for a moderator

Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

I have been discussing this as a follow on from discussion on the topic "fetching pop3 mail has suddenly stopped working for me." in another thread https://community.virginmedia.com/t5/Email/fetching-pop3-mail-has-suddenly-stopped-working-for-me/m-...

I thought I should start another thread with the right title, in case it catches the attention of someone with the same problem, or a good answer.

0 Kudos
Reply
  • 17.02K
  • 932
  • 6.79K
Superuser
Superuser
337 Views
Message 2 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

At least part of the problem is that smtp.virginmedia.com ONLY uses SMTPS on port 465 - (Note: This port was actually deprecated back in 1998 although many email providers use the port to this day).

Because port 465 is not a standard port many mail programs do not relay to this port.  Indeed sendmail originally ONLY sent to port 25 unencrypted although it can relay to port 587 instead.

However sendmail by default actually sends to Postfix on the same machine and it is actually Postfix that sends the outgoing mail.

So the best option is to actually modify Postfix to relay the outbound mail.  NOT least as the later versions of Postfix do actually support relaying using the tls wrapper mode on port 465 as well as port 587 StartTLS

To enable Postfix to use port 465 as a relay you need to add the following to /etc/main.cf in fedora

 

/etc/postfix/main.cf:
    # Client-side SMTPS requires "encrypt" or stronger.
    smtp_tls_security_level = encrypt
    smtp_tls_wrappermode = yes
smtp_tls_CAfile=/etc/ssl/certs/ca-bundle.crt # The [] suppress MX lookups. relayhost = [smtp.virginmedia.com]:465
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/mail/certs/cacert.pem

Note: The line in blue varies slightly according to what version of Linux you are using.  @aaronsloman is using Fedora so I have specifically used the crt file as it appears in that distribution.

 

The ca_bundle.crt is a list of root certificates that is needed to correctly authenticate the TLS/SSL certificates and comes bundled with most Linux distributions.  Possible locations are:

  • Fedora, CentOS                                   /etc/ssl/certs/ca-bundle.crt
  • Debian, Ubuntu/ Arch Linux              /etc/ssl/certs/ca-certificates.crt
  • OpenSuse                                           /etc/ssl/certs/ca-bundle.pem
  • FreeBSD                                              /etc/ssl/certs/cacert.pem

Now you need to create the password file.  We'll use nano

sudo nano /etc/postfix/sasl_passwd

Add the line:

[smtp.virginmedia.com]:465      <full email address>:<password>

Save the file by hitting Ctrl-X and then selecting yes.  Because the password here is stored in plain text then we need to make sure that it's only accessible by root.

sudo chmod 600 /etc/postfix/sasl_passwd

Next we need to process the password file so that Postfix can use it properly

sudo postmap /etc/postfix/sasl_passwd

Once you've run this command you'll see an additional file in the postfix directory call sasl_passwd.db

Finally once that's done you restart Postfix

sudo systemctl restart postfix.service

Note: This has been put together using some of the information from here:

https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/

And here:

http://www.postfix.org/postconf.5.html#smtp_sasl_security_optionshttp://www.postfix.org/postconf.5.h...

Tim

________________________________________


Only use Helpful answer if your problems been solved.

0 Kudos
Reply
  • 17.02K
  • 932
  • 6.79K
Superuser
Superuser
335 Views
Message 3 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

I should add that there is an alternative method where you install stunnel on your Fedora Box and then set it up so that a connection say to localhost port 2525 is then tunnelled to smtp.virginmedia.com port 465.  You can then reconfigure sendmail to send to localhost:2525

However you then also need to setup a passwd database in a similar way to how postfix is configured above.  The advantage to setting up postfix to relay is that we don't need any additional programs installed.

Tim 

________________________________________


Only use Helpful answer if your problems been solved.

0 Kudos
Reply
  • 403
  • 3
  • 39
aaronsloman
Fibre optic
329 Views
Message 4 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

Thanks for all that information. It is going to take time for me to digest and experiment, when I am less busy.

One thing that puzzles me is that your information suggests that postfix is used by default, whereas I have never previously installed or used it, since sendmail did exactly what I needed without using postfix, and still does if I post to smtp.blueyonder.co.uk.

In particular, I normally compose email in a programmable editor and when I send, the editor pipes the message text through sendmail. It may or may not be possible to treat postfix as a pipe in the same way.

I've just done a bit of research and found that postfix is claimed to be primarily for linux users who do not have an smtp server or connect to. E.g.

http://www.jancarloviray.com/blog/send-email-in-linux-without-an-smtp-server/

Anyhow, later, when I have time I'll make another attempt to post via smtp.virginmedia.com. For now I have no problem posting via smtp.blueyonder.co.uk

I'll report back when I have some news. I'll also find out what linux-using colleagues do.

Thanks very much for all your trouble. It should help other linux users switch to posting via virginmedia.com.

Aaron

0 Kudos
Reply
  • 17.02K
  • 932
  • 6.79K
Superuser
Superuser
325 Views
Message 5 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

I'm using Ubuntu myself.  I know Ubuntu comes with Postfix installed and the postfix package itself has it's own sendmail command, in fact I broke my main server by installing the separate sendmail packages Smiley Sad - Fortunately it was fairly painless to fix. (I am running my own mail server using mailinabox on a VPN with my own domains).

I did set up a Ubuntu install on an external drive a while ago and I did actually have the above working.

Tim

________________________________________


Only use Helpful answer if your problems been solved.

0 Kudos
Reply
  • 403
  • 3
  • 39
aaronsloman
Fibre optic
297 Views
Message 6 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

Thanks very much for taking all that trouble. Unravelling my current dependence on sendmail (including my code to invoke it in various places) and starting differently could be a lot of work. But it may be worth while. I'll have to read more, consult more linux experts and think!

I ran an ubuntu server remotely on Amazon (aws) for a few years, for various reasons. I got things to work but disliked it intensely (e.g. the structure of the libraries for 64bit and 32bit (legacy) programs). But I  know many people prefer it. In our CS department we mostly have redhat-based linux on our servers and desktop machines -- preferred by our computer officers -- but some individuals prefer ubuntu. I am also on a couple of linux user groups, which I should have consulted earlier about this. I'll do that now: if nobody already has a solution that works on fedora (e.g. tweaking sendmail scripts) I'll try your alternative.

Thanks again.

Aaron
PS. On the basis of  my recent experience I suspect VM will have to retain smtp.blueyonder.co.uk indefinitely. I don't know whether it's less secure.

0 Kudos
Reply
  • 17.02K
  • 932
  • 6.79K
Superuser
Superuser
289 Views
Message 7 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

I'll see if I can find what I've done with my hard drive and stick Fedora on it and let you know what happens Smiley Happy  However might be a couple of days.

Tim

________________________________________


Only use Helpful answer if your problems been solved.

0 Kudos
Reply
  • 403
  • 3
  • 39
aaronsloman
Fibre optic
264 Views
Message 8 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

Thanks very much. I don't really want you to go to a lot of trouble, as I am sure there must be a small change somewhere that will make sendmail work, and then I won't have to change my programs that invoke sendmail (e.g. the editor I use for composing and sending email).

I have had more suggestions from people in linux user groups including recommendations to try exim, and msmtp

At present posting to smtp.blueyonder works fine, so I don't think there's any hurry to switch to smtp.virginmedia.

0 Kudos
Reply
  • 403
  • 3
  • 39
aaronsloman
Fibre optic
232 Views
Message 9 of 11
Flag for a moderator

Re: Problems switching from smtp.blueyonder.co.uk to smtp.virginmedia.com using sendmail on linux

Minor update:

One of the options strongly recommended by another linux user is to use msmtp. This web site is very detailed and produces what looks like the functionality I am familiar with in sendmail   https://hostpresto.com/community/tutorials/how-to-send-email-from-the-command-line-with-msmtp-and-mu...

I had not previously mentioned the variety of uses I need. In my programmable editor (a bit like emacs but written in pop-11) I have commands to read received mail, to set up a reply, to start a new message, to add or remove Cc: or Bcc: lines or additional To: recipients, a Reply-To: field if needed (e.g. if I want any reply to go to two people).

I can also add mime-encoded attachments (I have an editor 'attach' command that takes a list of file names and creates the appropriate attachments inline (followed by a little hand editing) -- for text files, image files, pdf files, zip files, etc.

So the whole message becomes a long text file (which can be part of a longer file with previously sent or received messages, e.g. if I want to keep correspondence with one person or group in the same file, which makes text search for keywords very convenient.)

The editor send command simply sets up a linux sendmail command with appropriate arguments and then pipes the whole message text (including headers and attachments) through that sendmail process -- not the whole file, which normally contains many messages to/from the same recipient(s) or on the same topic.

[For anyone reading this who has never heard of unix/linux pipes see https://en.wikipedia.org/wiki/Pipeline_(Unix) ]

Probably nobody else would want to work like that, but it suits me very well and saves me a huge amount of time compared with other options I have tried, though it requires a little more care. I now have the impression that I'll be able to do something very similar with msmtp. It may also be possible with postfix, but I suspect more complicated and I am not sure that it is possible to pipe text into a postfix process.

If/when I get around to trying these options I'll report back here.

0 Kudos
Reply
  • 8
  • 0
  • 1
amidgley
Tuning in
90 Views
Message 10 of 11
Flag for a moderator

stunnel postfix smtp.virginmedia.com on Debian

I had it working a while back with stunnel, and then it didn't.  Now I'm trying to bring it back up with the direct route for Postfix, and the notes here are proving useful. 

Not working just yet, but I have hopes.

0 Kudos
Reply