- mutt_mktemp (tmp);
- if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
- mutt_perror (tmp);
- return (-1);
- }
- msg->path = m_strdup(tmp);
- return 0;
+ msg->fp = m_tempfile(tmp, sizeof(tmp), NONULL(Tempdir), NULL);
+ if (!msg->fp) {
+ mutt_perror(tmp);
+ return -1;
+ }
+
+ msg->path = m_strdup(tmp);
+ return 0;