Use sendmail with Reply To
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello,
I want to add a "Reply To" field in an email sent with Matlab's sendmail. I have tried
setpref('Internet','Reply_To','myOther@adress.com')
but it does not work. Any idea?
Thanks
댓글 수: 0
답변 (2개)
Dheeraj
2023년 9월 6일
Hi,
I understand that that you're trying to set the "Reply To" field for an email sent using MATLAB's “sendmail” function but the “setpref” method you mentioned is not the correct way to set the "Reply To" address. MATLAB's “sendmail” function does not have a direct option to set the "Reply To" field, so you'll need to craft the email headers manually through custom Headers.
Assuming “msg” is the MIME object and “smptServer”, “smtpUsername”, “smtpPassword” and recipient’s email is already generated.
This code block adds the “Reply-To" field to the custom header.
% Add the "Reply To" header where replyTo is the email address
msg.addHeader('Reply-To', replyTo);
% Add other headers (e.g., Subject, From, To)
msg.addHeader('Subject', subject);
msg.addHeader('From', sender);
msg.addHeader('To', recipient);
% Set the message body
msg.setBody(message, 'text/plain');
% Send the email
sendmail(smtpServer, smtpUsername, smtpPassword, recipient, msg);
You can refer to the below MATLAB documentation to have a better understanding about how to add fields to message.
I hope this helps!
댓글 수: 0
Mr64
2024년 11월 6일
Instead of 'Reply_To' use 'E_mail', i.e.
setpref('Internet','E_mail','myOther@adress.com')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Web Services에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!