1

I've been having this issue where I want to send a plaintext email to a user (me in this case) but the email adress is inside of an object I retrieved from the database. All examples using Mail::raw use a string but not a passed variable. Is there a way to do that?

Code:

Mail::raw($messageContent, function($message)
{
    $message->to($foo->email);
});

This is what I want, in essence. $foo is a variable declared in the function that this is in. I don't want to make $foo a class variable because I am only using it here.

Thanks for helping!

3
  • 2
    access the variable in the closure using use function($message) use ($foo) { ... Commented Oct 3, 2017 at 13:25
  • Ah let me try that! :) Commented Oct 3, 2017 at 13:37
  • Alright the 'to' part worked, what if I wanted to send it to a support email and add the user's email as 'from'? I don't seem to recieve an email then Commented Oct 3, 2017 at 13:50

1 Answer 1

2
    Mail::raw($suggestionString, function($message) use ($follower)
    {
        $message->to('[email protected]')->subject('Suggestion')->replyTo($follower->email);
    });

When you reply to this message it's automatically sent to the email specified in ->replyTo()

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

Comments

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.