How to send email "from" customer's email using SES - amazon-ses

I am a beginner developing my first site and I'm using AWS as my hosting platform. On my site I have a Contact Us form where the user can input their name, email and message then hit submit.
I am using SES to send the email from the Contact Us form, but I have a problem. I am aware that SES can only send emails from a verified email address, however I would like to set my From header to be the email address entered by the customer. This is so that when the mail arrives in my mail client it shows the customer's name on the left, next to the subject, before I click into the email.
I tried setting the Sender header to my verified email so that I could use the From header as the customer's one, but it made no difference.
I have been following this guide but as soon as I change <sender#example.com> to anything other than my verified email address it won't work.
The bash script which I'm using to send the email looks like this:
emailInput='AUTH LOGIN
*myBase64EncodedSMTPLogin*
*myBase64EncodedSMTPPassword*
MAIL FROM: '"${1}"'
RCPT TO: *my ses verified email address*
DATA
From: '"${2}"' <'"${1}"'>
To:
Subject: Message from *mysite.com*
'"${3}"'
.
QUIT'
echo "$emailInput" > ./tmpEmailInput.txt
openssl s_client -crlf -quiet -starttls smtp -connect *aws smtp endpoint* < tmpEmailInput.txt
rm ./tmpEmailInput.txt
In the above code, the arguments are as follows:
The first argument is the customer's email address.
The second is their name.
The third is their message.
If I change $1 in both places to my verified email address it works, but then in my mail client is says "me" as the sender, because the verified email address is both sending and receiving. I can only see the customer's name in the field at the top once I click into the email.
I would greatly appreciate some advice.
Thank you.

Related

Exim replace empty Subject

How to add "(No Subject)" automatically in emails sending with the subject is empty. My external smtp require a subject to send e-mails and display the error in this case:
SMTP<< 5.2.1 Subject is Mandatory

Exim - identify recipient BCC address

I'm using plus-addressing on Exim to create an automated system - I will process emails based on the local part of the address. So eg:
From: me#eximdomain.com
To: robot+project-4#eximdomain.com
This works well - I can process it based on the To address (specifically project-4). But ideally I want to be able to BCC an email to this address, eg:
From: me#eximdomain.com
To: somebody#otherdomain.com
Bcc: robot+project-4#eximdomain.com
When I am checking the mailbox for robot, I see the message, but nowhere in the header is the actual address that got it there, ie robot+project-4#eximdomain.com - so I cannot process it.
Obviously I do not want somebody#otherdomain.com to be aware of this address; but when robot#eximdomain.com receives it, I want to know that it was actually BCCd to robot+project-4#eximdomain.com (in some/any header).
Is there any way to do this?
Figured this out, if anyone comes across this: added this option to my local delivery transport (Dovecot LMTP in my case):
envelope_to_add = true
It then generates an Envelope-to header containing the incoming address.

How to create virtual email addresses with mailrule iredmail

I have been asked to create special mailbox with theese functions:
1) Create new mailbox test#domain.com (SMTP, POP3).
2) Incomming messages:
Arrange that this mailbox will recieve messages to virtual email addresses in test.xxx#domain.com form. Where xxx is any number with variable length. This is typically achieved in catch-all mailbox with regular expression mailrule (where TO or CC matches test\.\d+#domain.com)
3) Outgoing messages:
Enable login test#domain.com to send email with variable "FROM" field according to point 2) This is typically achieved by enabling any "FROM" for that mailbox.
Overall purpose of this mailbox is this:
There exists any reservation number in the system. For example 1500278.
employee sends email to client from CRM and email address test.1500278#domain.com and this email is registered in CRM.
Client replies to test.1500278#domain.com and this email is received to test#domain.com
system picks that mailbox using POP3 and assigns that email to reservation number 1500278.
so all need to know how to create this mail
the mail server running on Centos apache iRedMail
thanks for help.
done it by Memcached
and here is the link http://memcached.org/

email header "from" containing first and last names, not sender's email

I'm reading emails from pop3 server with zend mail component.
What I want is to know who is sent this email and when I try $message->from I see "FirstName LastName" without senders email.
I do print_r($message->getHeaders()) and do not see sender's email in any header from this email.
I thought that senders email is required and always must be set. Anything wrong here?
Is that possible to have email with "from" header with only First/Last name without email?
As per my comment:
if you print_r() a valid from header and the address is in angle brackets, you may only see it by viewing the HTML source, because the angle brackets and email address may be treated as an (albeit unrecognised) HTML tag, by the browser.
However, if anyone encounters this issue in the future (and the email address does not show in the HTML source), it is worth bearing in mind that the sender could have sent an email without a From: address, even though that is technically invalid.
Yes, this is totally possible. There are 2 usually "FROM" addressess with every email. 99% of the time, these are the same values, but they can be different. There is the MAIL FROM address that is used during the SMTP session, that issues the MAIL FROM command. Then, there is the FROM address found in the email message headers (this FROM address is sent during the SMTP DATA command). This is how you can get email spoofing.
Think of it this way (in the snail mail physical world). You can have a FROM address on the outside of an envelope (this would be equiv to the MAIL FROM command). This is supposed to be the person sending the message. You can then have a FROM value that is different on the letter head that is inside the envelope. This would be the FROM value you are seeing in the email headers.
Here is an example of some raw headers without a FROM address
From: "Steve James"
To: "John Doe" <you#yourcompany.com>
Date: Fri, 24 Feb 2012 07:43:40 -0800
Subject: Here is the progress report
....
Hopefully I didn't make that about as clear as mud.
--
Use the following format:
Firstname Lastname <vasya#poupkine.com>

Check if mail was successfully sent in VB.NET with SMTPClient

I'm trying to create an application that sends an email to an smtp-server.
The server is not set fixed, but will be looked up according to the domainpart of the email-address where the email should be sent to.
Example:
Email To: test#stackoverflow.com
Domain-Part: stackoverflow.com
Result of a MX-Record Lookup (commandline "nslookup -type=mx stackoverflow.com":
stackoverflow.com MX preference = 30, mail exchanger = stackoverflow.com.s9b1.psmtp.com
stackoverflow.com MX preference = 40, mail exchanger = stackoverflow.com.s9b2.psmtp.com
stackoverflow.com MX preference = 10, mail exchanger = stackoverflow.com.s9a1.psmtp.com
stackoverflow.com MX preference = 20, mail exchanger = stackoverflow.com.s9a2.psmtp.com
It would be quite useful, to know if the message was accepted by the mailserver and the message was successfully sent.
What I am able so far is, that I can get the SMTP-Server error code (if there was an error (StatusCode 5xx) by using the System.Net.Mail.SMTPClient Object and its SendAsync Function. There, if there was an error, I get an Exception-Object in the Callback-Event of the SMTPClient
I'm well aware that not every mailserver will tell me if the mailaccount truly exists and then reject my mail with an errorcode but instead just accept the message and then delete it. Therefore I would be grateful for another Method to check if the mail was sent (note: not read, that would be the read confirmation)
The final purpose would be:
Try to send an email to a recipient using it's domains mailserver and if it fails, proceed according to the errorcode (user does not exist -> abort / mailserver did not respond -> use another mailserver if available).
Thanks in advance (and sorry for typos :))
Unfortunately what you are looking for does not exist. Email jumps through so many hops that there is no definition of what "sent" actually means. For instance, your example of stackoverflow actually points to Postini's email servers. Postini probably passes the email around from gateways to AV's and routers. From there they either pool email or pass them on to another email server.
With email, the closest definition of "sent" is "at least I didn't get an error".
Also, a minor thing, but when using nslookup remember to add a trailing period to the domain, otherwise the domain search list is used. Generally not a big deal but every once in a while it might trip you up.
nslookup -type=mx stackoverflow.com.