drewr / postal

Clojure email support
MIT License
586 stars 85 forks source link

How to send own specific name while sending the email? #110

Closed RomitGandhi07 closed 3 years ago

RomitGandhi07 commented 4 years ago

Eg: I'm sending an email using abc@gmail.com and I want that the recipient will receive the email by XYZ name but currently they are getting an email with name either abc or email id itself.

Is there any way to specify a specific name? @drewr

dancek commented 4 years ago

First, if you're trying to spoof the sending address, that is up to the SMTP server, not the client.

Second, it's bad manners to request help in other issues.

RomitGandhi07 commented 4 years ago

@dancek Sorry for that, I deleted that comment.

I'm not trying to spoof but the issue is my email id is demo@gmail.com and in the Gmail, I have set my name as ABC XYZ but in the recipient side it is displaying email address instead of name.

dancek commented 4 years ago

Does ABC XYZ <demo@gmail.com> work?

RomitGandhi07 commented 4 years ago
(mail/send-message {:host "smtp.gmail.com"
                      :user "democera@gmail.com"
                      :pass "XXX"
                      :port 587
                      :tls true}
                     {:from "democera@gmail.com"
                      :to "XXX"
                      :subject "Final Demo"
                      :body [{:type "text/html"
                              :content "<font color=\"red\">Welcome</font>"}]})

This is the code that I have written, can you tell me where I should change?

drewr commented 3 years ago

You would use it with the from: key, for example: https://github.com/drewr/postal/blob/506072a314890f274c0d0921b05dbfa35e1b2665/test/postal/test/message.clj#L38

dpsutton commented 2 years ago

This was a helpful thread. I had thought the only way to accomplish this was to create an InternetAddress and use the constructor InternetAddress(String address, String personal). I didn't realize the that you could use the form Personal <email>. And it does not seem like we can pass in an InternetAddress as the from this is a nice way to accomplish this. Thank you.

drewr commented 2 years ago

Glad it was helpful @dpsutton 👍