Custom Confirmation Email based on title tag

The idea is to send different emails based on the title tag being identified and it won’t work. A little help please.

{% assign star_swag = false %}
{% for line in line_title %}
{% if line.title contains ‘Port’ %}
{% assign star_swag = true %}
{% endif %}
{% endfor %}
{% capture star_swag_email %} Thanks for purchasing this product. There is currently a small delay in shipping. We expect orders to be sent out by 21st February {% endcapture %}
{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
{% case delivery_method %}
{% when ‘pick-up’ %}
You’ll receive an email when your order is ready for pickup.
{% when ‘local’ %}
Hi {{ customer.first_name }}, we’re getting your order ready for delivery.
{% else %}
Hi {{ customer.first_name }}, we’re getting your order ready to be shipped. We will notify you when it has been sent.
{% endcase %}
{% if delivery_instructions != blank %}

Delivery information: We can not deliver

{% endif %} {% if star_swag == true %} Hi {{ customer.first_name }} {{ star_swag_email }} {% endif %} {% endif %} {% endcapture %}

Order confirmation

From what I read you make these changes in the notification email area. I have tried a bunch of different ways with no success at all. Not sure why the code seems current, the idea is to send to a collection group that I title with the same word and if that word is not there use he default one.