7

This might be a silly question, but I've looked here, here and here, and there is no mentioning whatsoever about those simple functionality.

Can I user the addHeader method for this cause?.

Thanks in advance for any help!.

1 Answer 1

10

Without more info about how you're actually sending the email (web?, smtp?, libraries?, etc), it's hard to give you a concise answer. That said, one of these three options should work:

1) If you're sending over HTTP with the web API

You can actually just add two extra parameters to your POST body, fromname and replyto, and send them along with the normal to, from, subject, etc.

Docs here: http://sendgrid.com/docs/API_Reference/Web_API/mail.html

2) If you're sending over SMTP with the PHP library

The PHP helper library (found here) has two helper methods, setReplyTo and setFromName to help you with that.

$mail = new SendGrid\Mail();
$mail->addTo('[email protected]')->
     setReplyTo('[email protected]')->
     setFromName('John Doe')->
     ...

3) If you're sending with SwiftMailer

SwiftMailer is a popular SMTP library for PHP. It has it's own helper methods from Reply to and From name. You can find more info in the docs (see setReplyTo and setFrom)

http://swiftmailer.org/docs/messages.html#the-structure-of-a-message

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot once again! I do have another issue though. If the message is send to multiple recipients(addTo in a foreach loop), do I need to set the replyTo, and the fromName per each recipient individually, or just once at the end. And also, why when I try to add a bcc for each mail t hat is sent out by SendGrid for testing purposes, the entire list of me recipients gets disclosed
There's a lot of questions in your comment. Mind contacting our support team (support.sendgrid.com) or opening up a new question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.